recognition of different cases

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

Réponses (1)

Azzi Abdelmalek
Azzi Abdelmalek le 1 Mai 2016

0 votes

yesorno = input('Run the function again? (Yes/No)\n','s')
Then compare upper(yesorno) with 'YES' or 'NO'

Cette question est clôturée.

Clôturé :

le 20 Août 2021

Community Treasure Hunt

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

Start Hunting!

Translated by