How to check if an object is NaN
Show older comments
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?
Accepted Answer
More Answers (0)
Categories
Find more on NaNs in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!