Azzera filtri
Azzera filtri

Strcmpi and while loop in a script

2 visualizzazioni (ultimi 30 giorni)
Riri
Riri il 19 Gen 2014
Modificato: Riri il 23 Gen 2014
Day=strcmpi('monday', 'monday')=1
Day=strcmpi('monday', 'friday')=0
answer=input('favorite day?' , 's')
Thanks to any help

Risposta accettata

Amit
Amit il 19 Gen 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 Commenti
Riri
Riri il 20 Gen 2014
can I use any other variable as a flag like a=0 while a==0
Amit
Amit il 21 Gen 2014
Yup. You can change tf to any variable name you want.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by