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: multiple statement in single loop
Replies: 1   Last Post: May 19, 2014 8:09 AM

Advanced Search

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

Posts: 312
Registered: 6/14/06
Re: multiple statement in single loop
Posted: May 19, 2014 8:09 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"ARSM" wrote in message <llc054$h95$1@newscl01ah.mathworks.com>...
> i have 2 set or array ,i want use value in array x=1:256 and y=2:257
> i try to make a loop but fail.
> this my loop
>
> for x=1:256 && y = 2:257
>
> a= x+y
>
> end


This won't work as written for several reasons. First, you would need nested loops. The && is a logical operator that is looking for a scalar logical result. You could rewrite your code to work in a loop, but why are you doing this anyway? Why not simply:

x = 1:256; y = 2:257;
a = x + y;

Barry



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.