IF Statements - case sensitive

I am writing an IF statement. The user is prompt to enter the word "play" to begin, how do I write it so it is not case sensitive. For example they could enter "Play" or pLay" or PLAy" and it would accept the word

Risposte (1)

Chad Greene
Chad Greene il 28 Feb 2014

0 voti

Try the strcmpi function.

1 Commento

For example:
user_input = 'plAy';
if strcmpi(user_input,'play')
disp('the user has input the word play')
end

Accedi per commentare.

Richiesto:

il 28 Feb 2014

Commentato:

il 28 Feb 2014

Community Treasure Hunt

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

Start Hunting!

Translated by