Matlab如何把cell转换成数值型。
36 ビュー (過去 30 日間)
古いコメントを表示
果博东方游戏网址【微8785092】
2023 年 5 月 17 日
回答済み: 果博东方官网【微8785092】
2023 年 5 月 17 日
如a(1X6的cell)
'1.025000e-06' '1.050000e-06' '1.075000e-06' '1.100000e-06' '1.125000e-06' '1.150000e-06'
0 件のコメント
採用された回答
果博东方官网【微8785092】
2023 年 5 月 17 日
楼主的代码有问题,用你的方法不行的。楼主可能是用这种方法生成的cell数组:
>>a={'1.025000e-06' '1.050000e-06' '1.075000e-06' '1.100000e-06' '1.125000e-06' '1.150000e-06'}
a =
'1.025000e-06' '1.050000e-06' '1.075000e-06' '1.100000e-06' '1.125000e-06' '1.150000e-06'
cell中的每个元素是一个含有数字的字符串。所以cell2mat就转换成了char类型的了。
用下面的方法:
a={'1.025000e-06' '1.050000e-06' '1.075000e-06' '1.100000e-06' '1.125000e-06' '1.150000e-06'};
num=length(a);
for ii=1:num
b(ii)=str2double(a{1,ii});
end
b
b =
Columns 1 through 5
1.025e-006 1.05e-006 1.075e-006 1.1e-006 1.125e-006
Column 6
1.15e-006
>>
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!