Info
この質問は閉じられています。 編集または回答するには再度開いてください。
if statements help, not compare
1 回表示 (過去 30 日間)
古いコメントを表示
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/257042/image.png)
if G>R
if R<0.8167
disp('orange class');
end
else
disp (' apple class');
end
code does not fall to the first if
0 件のコメント
回答 (1 件)
Walter Roberson
2019 年 12 月 24 日
You do not have an else corresponding to the if on line 2. The else that you have on the 5th line of your code corresponds to the else in line 6 of the algorithm.
You want
if this
if that
%this and that
else
%this but not that
end
else
%not this
end
but what you have is equivalent to
if this
if that
%this and that
end
%case of this but ~that was not tested
else
%not this
end
0 件のコメント
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!