将单元格转换为双倍 [英] Convert cell to double
本文介绍了将单元格转换为双倍的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
>> C = [{1} {2} ; {'@CF'} {2}]
C =
[ 1] [2]
'@CF' [2]
>> whos C
Name Size Bytes Class Attributes
C 2x2 478 cell
如何将 C
转换为 double
,以便:
>> C
C =
1 2
NaN 2
我试过 str2double(C)
。它返回:
NaN NaN
NaN NaN
推荐答案
使用 isnumeric ,由查询cellfun 。使用逻辑索引来提取数值:
Find the non numeric values with isnumeric, queried by cellfun. Use that with logical indexing to extract the numeric values:
C = [{1} {2} ; {'@CF'} {2}];
isnum = cellfun(@isnumeric,C);
result = NaN(size(C));
result(isnum) = [C{isnum}];
这篇关于将单元格转换为双倍的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文