필터 지우기
필터 지우기

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 CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by