'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 Center および File ExchangeEnvironment and Settings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by