Why doesn't the UNIQUE function work with NaNs ?

11 vues (au cours des 30 derniers jours)
MathWorks Support Team
MathWorks Support Team le 24 Août 2011
Why doesn't the UNIQUE function work with NaNs ?
For example:
>> unique([1 2 3 3 4 NaN NaN])
ans =
1 2 3 4 NaN NaN

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 24 Août 2011
NaNs are special values in that two NaNs are not equal to each other. For example:
>> NaN==NaN
ans =
0
This is why the NaNs in your vector are treated as different unique elements.
Also, you may wish to note that you can use the ISNAN function to check to data elements for NaNs.
A way to accomplish this functionality would use the attached function TSUNIQUE.

Plus de réponses (0)

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by