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!