Convert cell array to double
조회 수: 9 (최근 30일)
이전 댓글 표시
Hi guys,
I have a variable called MKVALM2PRSALEM came from
[~,~, MKVALM2PRSALEM] = xlsread('C:\Users\X...\199001.xlsx','Sheet1','M3:X502');
Part of the matrix is like,
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/147962/image.jpeg)
Notice that there are nulls like '@NA' and '@CF'.
How can I transfer this matrix into double format like the following picture, and keep all nulls like NaN?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/147964/image.jpeg)
When I tried to use str2double(MKVALM2PRSALEM), it returns a all nulls matrix. Actually I want to have the result like
MKVALM2PRSALEM = xlsread('C:\Users\X...\199001.xlsx','Sheet1','M3:X502');
But I can't directly use that syntax because MKVALM2PRSALEM actually comes from a larger cell array.
댓글 수: 0
채택된 답변
Jan
2012년 7월 17일
MKVALM2PRSALEM(cellfun(@ischar, MKVALM2PRSALEM)) = {NaN};
ABCDEFGHIJKLM_ = cell2mat(MKVALM2PRSALEM);
댓글 수: 0
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!