Day=strcmpi('monday', 'monday')=1
Day=strcmpi('monday', 'friday')=0
answer=input('favorite day?' , 's')
Thanks to any help

 채택된 답변

Amit
Amit 2014년 1월 19일

0 개 추천

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

Amit
Amit 2014년 1월 19일
btw, when you get the answer from a user that works for you, you should 'accept that answer'
Riri
Riri 2014년 1월 20일
Can you tell me what does tf mean ?
Amit
Amit 2014년 1월 20일
tf is just a flag that switches to 1 when both strings matches.
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개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2014년 1월 19일

편집:

2014년 1월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by