Strcmpi and while loop in a script

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by