If , while with or

How can I put or in "IF, While" function. For example:
While a<b or C<d
...
Cheers,

1 Commento

Jan
Jan il 11 Dic 2012
Reading the documentation has massive advantages.

Accedi per commentare.

Risposte (1)

Matt Fig
Matt Fig il 11 Dic 2012

1 voto

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;
end

3 Commenti

TAB
TAB il 11 Dic 2012
Modificato: TAB il 11 Dic 2012
Shouldn't it be like this ; )
while a<b || c<d
a = a + 1;
c = c * a;
end
Walter Roberson
Walter Roberson il 11 Dic 2012
In new versions (R2012a and later I think it is), "if" and "while" automatically short-circuit "|" and "&" operations with scalar arguments. This does not apply to "|" and "&" in any other logical expression
Jan
Jan il 11 Dic 2012
@Walter: The | operator in IF expressions apply short-circuiting in Matlab 6.5 already. As far as I remember in WHILE also.

Accedi per commentare.

Categorie

Scopri di più su MATLAB in Centro assistenza e File Exchange

Tag

Richiesto:

il 11 Dic 2012

Community Treasure Hunt

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

Start Hunting!

Translated by