MATLAB Answers

If , while with or

6 views (last 30 days)
jamaledin on 11 Dec 2012
How can I put or in "IF, While" function. For example:
While a<b or C<d
  1 Comment
Jan on 11 Dec 2012
Reading the documentation has massive advantages.

Sign in to comment.

Answers (1)

Matt Fig
Matt Fig on 11 Dec 2012
Did you look at the documentation?
doc while
In the documentation are examples.
a = 1;
b = 10;
c = 20;
d = 10000;
while a<b | c<d
a = a + 1;
c = c * a;
Jan on 11 Dec 2012
@Walter: The | operator in IF expressions apply short-circuiting in Matlab 6.5 already. As far as I remember in WHILE also.

Sign in to comment.


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by