Filter löschen
Filter löschen

Strcmpi and while loop in a script

1 Ansicht (letzte 30 Tage)
Riri
Riri am 19 Jan. 2014
Bearbeitet: Riri am 23 Jan. 2014
Day=strcmpi('monday', 'monday')=1
Day=strcmpi('monday', 'friday')=0
answer=input('favorite day?' , 's')
Thanks to any help

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by