Constructing a try-catch loop
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
sushma sharma
el 21 de Mayo de 2017
Editada: Walter Roberson
el 21 de Mayo de 2017
Hi,
I am trying to write a try-catch loop that will only fail on more than five attempts. how can i go about that?
So far, I have: try
%command to execute
catch
command to execute if error
end
how can i make this a loop that will only fail after five attempt at maximum?
any help would be appreciated,
sushma
0 comentarios
Respuesta aceptada
Walter Roberson
el 21 de Mayo de 2017
Editada: Walter Roberson
el 21 de Mayo de 2017
fail_count = 0;
for fail_count = 1 : 5
try
THIS
break; %stop on first success
catch
if fail_count == 5
THAT
end
end
end
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements 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!