Detect warning and take action
Mostrar comentarios más antiguos
I have a for loop and I call a function inside it. What I want to do, is detect if this function call created any warnings and if so continue. Something like:
for i=1:len
c = my_func1(arguments);
if (any warning)
continue;
end
end
Any suggestions? I tried to use lastwarn, without success though.
Respuesta aceptada
Más respuestas (2)
You can treat warnings as errors and thus catch them with a try ... catch statement, however, it is undocumented and may break in a future version. On the other hand, it's been there since 2004.
However, if you want to catch all warnings, you'll have to set them to error one by one since warning('error') or warning('error', 'all') is not supported, just warning('error', specificmsgid).
M
el 2 de Nov. de 2017
0 votos
This answer might help you :
1 comentario
Ioannis Nemparis
el 2 de Nov. de 2017
Categorías
Más información sobre Error Handling en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!