Convert cell to double
1 回表示 (過去 30 日間)
古いコメントを表示
Hi guys, I got a matrix C,
>>C = [{1} {2} ; {'@CF'} {2}]
C =
[ 1] [2]
'@CF' [2]
>>whos C
Name Size Bytes Class Attributes
C 2x2 478 cell
How can I transfer C into double so that:
>>C
C =
1 2
NaN 2
I've tried Str2double(C), it doesn't work. It returns,
NaN NaN
NaN NaN
2 件のコメント
Jan
2012 年 7 月 17 日
Of course STR2DOUBLE does not work, because the elements of your cell matrix are not strings.
Btw, you can write the cell tighter as: {1, 2; '@CF', 2}
Walter Roberson
2012 年 7 月 17 日
回答 (1 件)
Honglei Chen
2012 年 7 月 17 日
編集済み: Honglei Chen
2012 年 7 月 17 日
Your C already contains numbers, so those cells are invalid for str2double
C(~cellfun(@isnumeric,C))={nan}
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!