If , while with or

조회 수: 4 (최근 30일)
jamaledin
jamaledin 2012년 12월 11일
How can I put or in "IF, While" function. For example:
While a<b or C<d
...
Cheers,
  댓글 수: 1
Jan
Jan 2012년 12월 11일
Reading the documentation has massive advantages.

댓글을 달려면 로그인하십시오.

답변 (1개)

Matt Fig
Matt Fig 2012년 12월 11일
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
Walter Roberson
Walter Roberson 2012년 12월 11일
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 2012년 12월 11일
@Walter: The | operator in IF expressions apply short-circuiting in Matlab 6.5 already. As far as I remember in WHILE also.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by