Operands to the || and && operators must be convertible to logical scalar values error
2 ビュー (過去 30 日間)
古いコメントを表示
Faustino Quintanilla
2017 年 11 月 13 日
コメント済み: Walter Roberson
2017 年 11 月 13 日
I get an operators error... Not sure why. Can you help out?
Here is the code:
while count<=i
mfg=G(count)
if mfg == 27 && mfgdate2 >= 1946 && mfgdate<= 1974 || mfg == 27 && mfgdate>= 1983 && mfgdate<= 1988
MfgScore(count,:)=3;
end
count=count+1;
end
0 件のコメント
採用された回答
Walter Roberson
2017 年 11 月 13 日
Either mfgdate or mfgdate2 are not scalar. You probably need to index them with count
It is suspicious that you use mfgdate2 only once in the expression
0 件のコメント
その他の回答 (1 件)
Faustino Quintanilla
2017 年 11 月 13 日
1 件のコメント
Walter Roberson
2017 年 11 月 13 日
I find it suspicious that
elseif mfg == 27 && mfgdate2(count)>= 1946 && mfgdate(count)<= 1974 || mfg == 27 && mfgdate(count)>= 1983 && mfgdate(count)<= 1988
is the only place that uses mfgdate instead of mfgdate2, and that in the middle of the expression mfgdate2 is the lower bound but mfgdate is the upper bound. It would make more sense to me if you had
elseif mfg == 27 && mfgdate2(count)>= 1946 && mfgdate2(count)<= 1974 || mfg == 27 && mfgdate(count)>= 1983 && mfgdate(count)<= 1988
参考
カテゴリ
Help Center および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!