how to display a error message then proced further when the string doesnot matches by using for and if loop
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (3)
Chandrasekhar
el 7 de Mzo. de 2014
try
....your code
catch exception
disp(exception.message)
end
0 comentarios
Walter Roberson
el 7 de Mzo. de 2014
trycount = 0;
while trycount < 3
....
if no match
trycount = trycount + 1
end
end
if trycount >= 3
user blew it
end
Ver también
Categorías
Más información sobre Get Started with MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!