how i have reaction against error received of matlab?

1 visualización (últimos 30 días)
xosro
xosro el 14 de Jul. de 2015
Editada: Walter Roberson el 18 de Jul. de 2015
i have a for loop with a condition on receive or not receive a error of matlab program, how i can have this condition?

Respuesta aceptada

Walter Roberson
Walter Roberson el 15 de Jul. de 2015
for variable = first : last
got_error = true;
try
do something risky here
got_error = false; %only gets here if the risky thing worked
catch ME
do something about the error; the details of it are in ME
end
if got_error
we had an error and did something with it but maybe we want to know that later
end
end
  1 comentario
xosro
xosro el 18 de Jul. de 2015
Editada: Walter Roberson el 18 de Jul. de 2015
hi mr roberson
i fix this problem (do something risky here) by
if (strcmp(me.message,'my intended error.'))
do something about the error;
else
rethrow(me);
end
thank you about your perfect comments.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by