フィルターのクリア

Convert cell array to double

9 ビュー (過去 30 日間)
Xiao Tang
Xiao Tang 2012 年 7 月 17 日
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,
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?
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.

採用された回答

Jan
Jan 2012 年 7 月 17 日
MKVALM2PRSALEM(cellfun(@ischar, MKVALM2PRSALEM)) = {NaN};
ABCDEFGHIJKLM_ = cell2mat(MKVALM2PRSALEM);

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 7 月 17 日
MKVALM2PRSALEM(cellfun(@ischar, MKVALM2PRSALEM)) = {NaN};
  1 件のコメント
Xiao Tang
Xiao Tang 2012 年 7 月 17 日
Thanks Walter. But the format of MKVALM2PRSALEM is still in cell array, rather than double.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by