I am trying to build this code to where I can type either YES or NO when asked for the input in line 1, but whenever I type NO, an error pops up saying "Matrix dimensions must agree". I am not sure where I am going wrong.
1 回表示 (過去 30 日間)
古いコメントを表示
tail_stinger = input('Has a tail/stinger?','s');
if tail_stinger == 'YES'
straight_tail = input('Tail straight like a needle?','s');
if straight_tail == 'YES'
disp('Order Uropygi')
else straight_tail = 'NO';
disp('Order Scorpiones')
end
else tail_stinger = 'NO';
claws = input('Has claws?','s');
if claws == YES
length_flat = input('Less than 5mm long or flat?','s');
if length_flat == YES
disp('Order Pseudoscorpiones')
else
disp('Order Amblypygi')
end
end
end
0 件のコメント
回答 (1 件)
JESUS DAVID ARIZA ROYETH
2017 年 9 月 21 日
for compare two strings use strcmp :
if strcmp(tail_stinger,'YES')
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!