Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Index out of bounds error
Replies: 4   Last Post: Feb 6, 2013 2:32 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
dpb

Posts: 8,231
Registered: 6/7/07
Re: Index out of bounds error
Posted: Feb 6, 2013 2:32 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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)...

--



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.