how to display a error message then proced further when the string doesnot matches by using for and if loop

this is my program
list={'AOA','CAS','IAS','ALT'};
prompt='Enter variable name';
a=input(prompt,'s');
b=strcmp(a,list);
if input does not matches with the list of variables then it must show an error 'Variable not found, please try again' (for three times) & if the user enters invalid variable for three times the program should be terminated.

답변 (3개)

trycount = 0;
while trycount < 3
....
if no match
trycount = trycount + 1
end
end
if trycount >= 3
user blew it
end

댓글 수: 1

just have a look on my program once again the last statement will store 1 or 0 in variable now i want to display an error when m=0 so how to do ??

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Filename Construction에 대해 자세히 알아보기

질문:

2014년 3월 7일

댓글:

2014년 3월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by