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: how to fix subscript indices must either be real positive integers or logicals?
Replies: 4   Last Post: Aug 28, 2013 2:06 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,106
Registered: 6/7/07
Re: how to fix subscript indices must either be real positive integers
or logicals?

Posted: Aug 28, 2013 1:49 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 8/28/2013 12:18 PM, p v bhumireddi wrote:
> im new to matlab.im executing program and im getting repeatedly the
> above mentioned error
> my code is w=[2:5];
> int=0;
> for k=1:w
> e(int)=[exp(i*k) exp(2*i*k)];
> int=int+1;
> end can anyone help me.urgent


What's the value of 'int' the first pass thru when it is used as the
index to the array e? Matlab arrays are 1-based.

One line of code rearrangement will resolve that problem at which time
you'll discover a few more.

for k=1:w

won't return what you expect

doc for

for why and how to correct it.

--




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.