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 vue (au cours des 30 derniers jours)
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

Réponses (1)

JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH le 21 Sep 2017
for compare two strings use strcmp :
if strcmp(tail_stinger,'YES')

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by