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

回答 (1 件)

JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH 2017 年 9 月 21 日
for compare two strings use strcmp :
if strcmp(tail_stinger,'YES')

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by