How to get TRUE/FLASE to work for arrays of cells with mixed string and integer values?
Mostrar comentarios más antiguos
I have a 1x14 cell array:
data{1} = 9 9 NaN 6 19 8 17 7 15 31 6 18 4 13
I am trying to apply a T/F logic test to it:
tf = data{1} == NaN;
But I get 1x14 vector of zeroes, doesn't seem to work for non-integers.
Whats the best way to check for a string value?
The end goal is to remove the cells containing 'NaN' from the array.
Thank you!
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 13 de Oct. de 2012
Editada: Walter Roberson
el 13 de Oct. de 2012
You need to use isnan() to compare to NaN. NaN does not test equal to anything, including itself.
NaN == NaN
will give false.
You do not show any strings in your sample input.
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!