Borrar filtros
Borrar filtros

Trying to pass/ignore an Error in a loop.

4 visualizaciones (últimos 30 días)
nicolas
nicolas el 7 de Abr. de 2013
I have a loop that check the best parametrers in many timeseries, but there are some of them where Matlab cannot check, so the loop is stopping. In those cases i just want the loop to continue, ignoring the error. I am thinking "for i=1:1000 ... if find an error go to i+1 " but there is something like this??
Thanks!

Respuesta aceptada

Wayne King
Wayne King el 7 de Abr. de 2013
Editada: Wayne King el 7 de Abr. de 2013
Without more detail, I don't know if this will work in your scenario, but one possibility is a try block
x = randn(3,2);
y = randn(3,2);
try
z = x*y;
catch ME
z = x.*y;
end
If an error occurs in the catch end block, then the execution will stop unless you catch that error with a try -- catch
  4 comentarios
nicolas
nicolas el 7 de Abr. de 2013
ok ok, i understand. I ll try this later, because now its still running, until it finds an error again! Thanks for your time!
nicolas
nicolas el 7 de Abr. de 2013
its working! for k=1:100 try .... catch error end end
%%and the loop continues ignoring the error thanks!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by