Is there a way to throw an error whenever NaN occurs
29 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hechuan Wang
le 31 Mai 2017
Commenté : Hechuan Wang
le 31 Mai 2017
In most of my work, NaN is not a possible value. However NaN will not stop Matlab from working, so the error will occur some where after NaN happened. This is a trouble for me because the error message only shows the location where that NaN caused an error, but what I need is to find out where NaN was created.
What I wish is, NaN is set to be a kind of error, or throw an error whenever NaN occurs.
Is there anything that I can do?
Thanks
0 commentaires
Réponse acceptée
Steven Lord
le 31 Mai 2017
No, you cannot directly make MATLAB throw an error when a NaN is created. But you can do something close to what you wish. One of the types of "Advanced Error Breakpoint Configuration" that you can set will cause MATLAB to stop execution when an Inf or NaN occurs. Search the documentation page to which I linked for that subsection title for more information.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur NaNs dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!