Matlab如何把cell转换成数值型。

조회 수: 36 (최근 30일)
果博东方游戏网址【微8785092】
如a(1X6的cell)
'1.025000e-06' '1.050000e-06' '1.075000e-06' '1.100000e-06' '1.125000e-06' '1.150000e-06'

채택된 답변

果博东方官网【微8785092】
楼主的代码有问题,用你的方法不行的。楼主可能是用这种方法生成的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개)

카테고리

Help CenterFile Exchange에서 编程에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!