matlab如何将cell型变成double型呢?
1、先把cell转变成char数组,在把他转变成数据类型.原理是转变成char之后的矩阵每行的长度是相同的.[plain] view plaincopystr2num(char(cdata))
2、使用cellfun函数,第一个参数传递对每个cell单元使用的函数名,第二个参数是cell名.[plain] viewplaincopycellfun(@str2num, cdata)
3、元胞数组的元素都是矩阵呀,转化完后也是矩阵。clear all;clc;test ={'1','1','1','1','2','2','2','2','3','3','3','3','4','4','4','4'};
for n=1:length(test)
x{n}=str2num(test{n});
end
x =
Columns 1 through 10
[1] [1] [1] [1] [2] [2] [2] [2] [3] [3]
Columns 11 through 16
[3] [3] [4] [4] [4] [4]
>> class(x{1})
ans