Convert cell to double

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
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}

댓글을 달려면 로그인하십시오.

답변 (1개)

Honglei Chen
Honglei Chen 2012년 7월 17일
편집: Honglei Chen 2012년 7월 17일

0 개 추천

Your C already contains numbers, so those cells are invalid for str2double
C(~cellfun(@isnumeric,C))={nan}

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

질문:

2012년 7월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by