Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
dpb
Posts:
6,677
Registered:
6/7/07
|
|
Re: Index out of bounds error
Posted:
Feb 6, 2013 2:32 PM
|
|
On 2/6/2013 12:02 AM, Nicholas wrote: > I'm extremely new to programming and have very limited experience in > matlab. I've gone through the debug mode with no luck. It doesn't make > sense that, even though I'm inputting 51 as the number of nodes, my code > is telling me Nx = 50.
Well, it's not actually telling you that, precisely. The actual error is that numel(u_0) == 50. That's not _quite_ the same thing as Nx==50. Perhaps inadvertently in your code an element in u_0 was deleted so the array isn't the same length as Nx.
Remember in debugging to look at precisely what the code says w/o allowing yourself to read into it what you intended. Somewhere I'll bet you've made a simple "off-by-one" mistake if the problem wasn't traced back to the previous suggestion of perhaps the code you're running isn't the same as that you're looking at.
If you still are having trouble and can make a self-contained case that shows the problem that cs-sm readers can cut'n paste into their command line, then surely somebody will be able to pick up on where the problem is. Unfortunately, in what you've posted so far it does appear as though it should be ok (at least to my old eyes)...
--
|
|
|
Date
|
Subject
|
Author
|
|
2/5/13
|
|
dpb
|
|
2/6/13
|
|
dpb
|
|
2/6/13
|
|
dpb
|
|
|