Strcmpi and while loop in a script

1 回表示 (過去 30 日間)
Riri
Riri 2014 年 1 月 19 日
編集済み: Riri 2014 年 1 月 23 日
Day=strcmpi('monday', 'monday')=1
Day=strcmpi('monday', 'friday')=0
answer=input('favorite day?' , 's')
Thanks to any help

採用された回答

Amit
Amit 2014 年 1 月 19 日
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 件のコメント
Riri
Riri 2014 年 1 月 20 日
can I use any other variable as a flag like a=0 while a==0
Amit
Amit 2014 年 1 月 21 日
Yup. You can change tf to any variable name you want.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by