use of short Circuit operator
1 回表示 (過去 30 日間)
古いコメントを表示
Hi, How can I use short circuit operators(&&) in vector variable?
0 件のコメント
採用された回答
Walter Roberson
2012 年 10 月 15 日
You cannot. && can only be used for scalars.
Note that if you are trying to code something like
if vector1 && vector2
then the "if" would be considered true only if all values in "vector1 && vector2" evaluated to true, because that is how "if" behaves on vectors and matrices, as if there was an all() wrapped around everything:
if all(vector1 && vector2)
With some minor thought on the meaning of "&" you can see this would be the same as
if all(all(vector1) && all(vector2))
which could be written more briefly as
if all(vector1) && all(vector2)
which is allowed.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Visualization and Data Export についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!