Replace String with a NaN in table
Mostrar comentarios más antiguos
Hey guys!
I am challenged with a table, consisting various numbers and a few "'Bad'" cells. I guess they are strings. My goal now is to replace these "Bads" with NaNs.
How do I achieve that the easiest way?
Best regards, Spacey
1 comentario
per isakson
el 24 de Mzo. de 2015
"table"   is that
Respuesta aceptada
Más respuestas (3)
Konstantinos Sofos
el 24 de Mzo. de 2015
Editada: Konstantinos Sofos
el 24 de Mzo. de 2015
Hi,
" I guess they are strings" ...you cannot open your table or see in the workspace what type are they?
Do you mean something like the following:
>> A = {'xx',5,6,'''',78,'?..'}
A =
'xx' [5] [6] ''' [78] '?..'
>> idx = cellfun(@(x) ischar(x),A)
idx =
1 0 0 1 0 1
>> A(idx)={NaN}
A =
[NaN] [5] [6] [NaN] [78] [NaN]
>> B = cell2mat(A)
B =
NaN 5 6 NaN 78 NaN
>> whos
Name Size Bytes Class Attributes
A 1x6 408 cell
B 1x6 48 double
Jos (10584)
el 24 de Mzo. de 2015
1 voto
Take a look at CELL2FLOAT
Spacey
el 24 de Mzo. de 2015
0 votos
Categorías
Más información sobre Characters and Strings en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!