How to check if an object is NaN
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Bruno Luong
el 24 de Ag. de 2023
Comentada: Dyuman Joshi
el 24 de Ag. de 2023
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 comentarios
Respuesta aceptada
Walter Roberson
el 24 de Ag. de 2023
https://www.mathworks.com/help/matlab/ref/isequaln.html
1 comentario
Dyuman Joshi
el 24 de Ag. de 2023
How exactly will this work?
Suppose the input is {NaN}, how to check for this?
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!