'Or' statement in matlab?

조회 수: 25 (최근 30일)
Aadil
Aadil 2012년 9월 7일
편집: Simran Wasu 2016년 2월 20일
How can I do this without using else if?:
if balls == 0 & ( x > 5 OR y > 7)
run xscript
end
Thanks,
  댓글 수: 4
José-Luis
José-Luis 2012년 9월 7일
Image Analyst understood faster and gave you the answer...
Simran Wasu
Simran Wasu 2016년 2월 20일
편집: Simran Wasu 2016년 2월 20일
use '||' for OR command (without quotes).

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

채택된 답변

Image Analyst
Image Analyst 2012년 9월 7일
편집: Image Analyst 2012년 9월 7일
You need two &&:
if balls == 0 && ( x > 5 || y > 7)
% run xscript
xscript();
end
  댓글 수: 5
Image Analyst
Image Analyst 2012년 9월 7일
I've seen that before - where the vertical lines don't appear. However I can't reproduce anymore. For me | appears both in regular text, and code formatted text. By the way, I edited by answer to change "run xscript" to be just "xscript" since the "run" command like you had is not needed.
Aadil
Aadil 2012년 9월 7일
ok thanks everyone

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by