How to check if an object is NaN
12 ビュー (過去 30 日間)
古いコメントを表示
I want to check a generic object "is equal" to NaN.
The command isnan(object) throws an error and the command isequal(object, NaN) returns false if object is NaN.
So my attempt is this rather complicated expression
isobjecteqNaN = @(object)isa(object,'double') && isscalar(object) && isnan(object);
isobjecteqNaN(NaN)
isobjecteqNaN({NaN})
Is there any better way to check?
0 件のコメント
採用された回答
Walter Roberson
2023 年 8 月 24 日
https://www.mathworks.com/help/matlab/ref/isequaln.html
1 件のコメント
Dyuman Joshi
2023 年 8 月 24 日
How exactly will this work?
Suppose the input is {NaN}, how to check for this?
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!