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

 采纳的回答

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 个评论

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

请先登录,再进行评论。

更多回答(0 个)

类别

在 帮助中心 和 File 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