How to check if an object is NaN
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Bruno Luong
le 24 Août 2023
Commenté : Dyuman Joshi
le 24 Août 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 commentaires
Réponse acceptée
Walter Roberson
le 24 Août 2023
https://www.mathworks.com/help/matlab/ref/isequaln.html
1 commentaire
Dyuman Joshi
le 24 Août 2023
How exactly will this work?
Suppose the input is {NaN}, how to check for this?
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!