Replace String with a NaN in table
Ältere Kommentare anzeigen
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 Kommentar
per isakson
am 24 Mär. 2015
"table"   is that
Akzeptierte Antwort
Weitere Antworten (3)
Konstantinos Sofos
am 24 Mär. 2015
Bearbeitet: Konstantinos Sofos
am 24 Mär. 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)
am 24 Mär. 2015
1 Stimme
Take a look at CELL2FLOAT
Spacey
am 24 Mär. 2015
0 Stimmen
Kategorien
Mehr zu Characters and Strings finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!