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: 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$>...
> 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;


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.