Is there a way to throw an error whenever NaN occurs

31 ビュー (過去 30 日間)
Hechuan Wang
Hechuan Wang 2017 年 5 月 31 日
コメント済み: Hechuan Wang 2017 年 5 月 31 日
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 Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by