Strcmpi and while loop in a script

조회 수: 2 (최근 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 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