recognition of different cases
Info
This question is closed. Reopen it to edit or answer.
Show older comments
In an assignment for class, one of the problems asks for a function that recognizes any variation of "yes" or "no," such as yES, YEs, No, nO. The question suggests we use the "upper" command. Here's what I have so far, but I feel like I'm approaching it incorrectly
% code
end
yesorno = input('Run the function again? (Yes/No)\n');
yes = 1;
no = 2;
if yesorno == 1
disp('Function restart...')
else
end
Answers (1)
Azzi Abdelmalek
on 1 May 2016
yesorno = input('Run the function again? (Yes/No)\n','s')
Then compare upper(yesorno) with 'YES' or 'NO'
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!