how to display a error message then proced further when the string doesnot matches by using for and if loop
조회 수: 1 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
답변 (3개)
Walter Roberson
2014년 3월 7일
trycount = 0;
while trycount < 3
....
if no match
trycount = trycount + 1
end
end
if trycount >= 3
user blew it
end
참고 항목
카테고리
Help Center 및 File Exchange에서 Downloads에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!