Is there a way to throw an error whenever NaN occurs

29 次查看(过去 30 天)
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

采纳的回答

Steven Lord
Steven Lord 2017-5-31
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 NaNs 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by