Info

この質問は閉じられています。 編集または回答するには再度開いてください。

enter in the if clause only in certain situation

2 ビュー (過去 30 日間)
Salvatore Mazzarino
Salvatore Mazzarino 2012 年 9 月 20 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I would execute a block only if I have this vector
A=[1 0]
instead if I'd have A=[0 0] or A=[1 1] if clause shouldn't be executed. I tried using any or all functions but I'm little confused with their use...
  1 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 9 月 20 日
can you be more clear,

回答 (1 件)

Andrew Barton
Andrew Barton 2012 年 9 月 20 日
I think all(A==[1 0]) is what you're looking for. A==[1,0] returns a 1x2 array where the first element is true if A(1) == 1, and the second element is true if A(2) == 0. All takes that 1x2 array and only returns true if each of its elements are true.

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by