IF Statements - case sensitive

7 visualizaciones (últimos 30 días)
Allyson
Allyson el 28 de Feb. de 2014
Comentada: Chad Greene el 28 de Feb. de 2014
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

Respuestas (1)

Chad Greene
Chad Greene el 28 de Feb. de 2014
Try the strcmpi function.
  1 comentario
Chad Greene
Chad Greene el 28 de Feb. de 2014
For example:
user_input = 'plAy';
if strcmpi(user_input,'play')
disp('the user has input the word play')
end

Iniciar sesión para comentar.

Categorías

Más información sobre Variables en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by