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!