フィルターのクリア

Checking if sides of triangle are positive and if equality rule is satisfied.

1 回表示 (過去 30 日間)
David
David 2013 年 10 月 2 日
コメント済み: David 2013 年 10 月 2 日
So, I could easily do this using multiple if statements but that seems fairly repetitive. Is there an and or operator in MATLAB so that I could say: if a <= 0 and or b <= 0 and or c <= 0 error... end
And, then do a similar thing with the equality. Sorry for the fairly simple questions, first week or so using MATLAB.

採用された回答

Matt J
Matt J 2013 年 10 月 2 日
if any([a,b,c]<=0)
  9 件のコメント
Matt J
Matt J 2013 年 10 月 2 日
編集済み: Matt J 2013 年 10 月 2 日
I can't tell what it's attempting to test. That's what I meant when I said it doesn't make sense.
Aside from that, though, if you run it, you will get an error. The short-circuited logical operators "&&" and "||" only apply to scalar expressions, not vectors.
David
David 2013 年 10 月 2 日
Gotcha. Just looked up the any()operation and I understand it now. Thanks.

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2013 年 10 月 2 日
if a<=0 || b<=0 || c<=0
% It's bad
end
  4 件のコメント
David
David 2013 年 10 月 2 日
編集済み: David 2013 年 10 月 2 日
Btw, the above is a genuine question, not me trying to disprove you.
David
David 2013 年 10 月 2 日
Thanks!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by