Search All of the Math Forum:

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

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

Topic: multiple statement in single loop
Replies: 1   Last Post: May 19, 2014 8:09 AM

 Messages: [ Previous | Next ]
 Barry Williams Posts: 312 Registered: 6/14/06
Re: multiple statement in single loop
Posted: May 19, 2014 8:09 AM

"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

Date Subject Author
5/19/14 ARSM
5/19/14 Barry Williams