フィルターのクリア

Operands to the || and && operators

4 ビュー (過去 30 日間)
Maria hassan
Maria hassan 2016 年 12 月 7 日
回答済み: Steven Lord 2016 年 12 月 7 日
Hi,
I am getting this massage: Operands to the and && operators must be convertible to logical scalar values.
Error in main (line 27) elseif model==2 model==3
what does this mean please regards

回答 (1 件)

Steven Lord
Steven Lord 2016 年 12 月 7 日
In the expression X && Y or X || Y, X and Y must both be scalar (as defined by isscalar, meaning the values have size [1 1]) and the commands logical(X) and (if necessary) logical(Y) must succeed.
Cases that will not work:
% X is not scalar
[1 2] && 1
[] && 1
% X cannot be converted to a logical
NaN && 5
Cases that will work:
% Both scalar, both convertible to logical
1 && 0
true && true
% X causes the comparison to short-circuit so Y is not checked
false && [1 2] % false AND anything is false
true || NaN % true OR anything is true

カテゴリ

Help Center および File ExchangeSwitches and Breakers についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by