Strcmpi and while loop in a script

Day=strcmpi('monday', 'monday')=1
Day=strcmpi('monday', 'friday')=0
answer=input('favorite day?' , 's')
Thanks to any help

 Respuesta aceptada

Amit
Amit el 19 de En. de 2014
tf = 0;
comp_fav_day = 'monday'; %Lets say
while (tf == 0)
answer=input('favorite day?\n' , 's');
tf = strcmpi(comp_fav_day,answer);
end

5 comentarios

Amit
Amit el 19 de En. de 2014
btw, when you get the answer from a user that works for you, you should 'accept that answer'
Riri
Riri el 20 de En. de 2014
Can you tell me what does tf mean ?
Amit
Amit el 20 de En. de 2014
tf is just a flag that switches to 1 when both strings matches.
Riri
Riri el 20 de En. de 2014
can I use any other variable as a flag like a=0 while a==0
Amit
Amit el 21 de En. de 2014
Yup. You can change tf to any variable name you want.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 19 de En. de 2014

Editada:

el 23 de En. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by