Replace String with a NaN in table
古いコメントを表示
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 件のコメント
per isakson
2015 年 3 月 24 日
"table"   is that
採用された回答
その他の回答 (3 件)
Konstantinos Sofos
2015 年 3 月 24 日
編集済み: Konstantinos Sofos
2015 年 3 月 24 日
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)
2015 年 3 月 24 日
1 投票
Take a look at CELL2FLOAT
カテゴリ
ヘルプ センター および File Exchange で Characters and Strings についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!