如何将一个字符串转换为数字数组?例如:
我编写了下面的代码,但是它存在问题。
str = '1,2,3,4.5',转换成number = [1 2 3 4.5]
。我编写了下面的代码,但是它存在问题。
str='1,2,3,4.5';
tmp = regexp (str,',','split');
tmp2=[];
for(i=1:length(tmp))
tmp2(i)=cell2mat(tmp(i))
end