How is a logical array evaluated as an if condition?

 採用された回答

Steven Lord
Steven Lord 2017 年 3 月 17 日

0 投票

" if expression, statements, end evaluates an expression, and executes a group of statements when the expression is true. An expression is true when its result is nonempty and contains only nonzero elements (logical or real numeric). Otherwise, the expression is false."
Your vector logical([0 0 1]) is nonempty, but it does not contain only nonzero elements. So the expression is false and the body of your if statement is not executed.

その他の回答 (0 件)

カテゴリ

質問済み:

2017 年 3 月 17 日

回答済み:

2017 年 3 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by