Effacer les filtres
Effacer les filtres

Convert cell to double

1 vue (au cours des 30 derniers jours)
Xiao Tang
Xiao Tang le 17 Juil 2012
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 commentaires
Jan
Jan le 17 Juil 2012
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
Walter Roberson le 17 Juil 2012

Connectez-vous pour commenter.

Réponses (1)

Honglei Chen
Honglei Chen le 17 Juil 2012
Modifié(e) : Honglei Chen le 17 Juil 2012
Your C already contains numbers, so those cells are invalid for str2double
C(~cellfun(@isnumeric,C))={nan}

Catégories

En savoir plus sur Cell Arrays dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by