The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: For Loop Problem
Replies: 2   Last Post: Feb 13, 2013 9:22 AM

Advanced Search

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

Posts: 18,038
Registered: 12/7/04
Re: For Loop Problem
Posted: Feb 13, 2013 9:22 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Pete " <> wrote in message
> Hi,
> I am trying to use a For Loop to assign each individual number in a 31x1
> matrix a letter. I have tried to create a For loop but i keep getting an
> error saying that it cannot label the point as there are not enough points
> in the matrix, i.e there are 31 numbers in the matrix and it is trying to
> find the 32nd. What am i doing wrong? Here is what i have at the moment:
> for j=1:length(Tr)
> A=Tr(j);
> B=Tr(j+1);

When j is equal to length(Tr), Tr(j+1) is one past the end of the array. How
to fix this depends on what exactly you're trying to do. There are likely
ways to do what you described without a loop, depending on the specific
details behind your individual numbers. Are they integer values? Are they
unique? What criteria are you using to generate the number -> letter
mapping? If you post more information to the newsgroup, people may be able
to offer more specific suggestions.

Steve Lord
To contact Technical Support use the Contact Us link on

Date Subject Author
Read Re: For Loop Problem
Read Re: For Loop Problem
Steven Lord

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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.