
Matlab怎样合并cell类型的数组和double类型数组
1个回答
展开全部
元胞数组的元素都是矩阵呀,转化完后也是矩阵
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 =
double
---------------------------------------------------------
如果不想要元胞数组,可以加一句转化一下:
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
for m=1:length(x)
y(m)=x{m}(1)
end
y =
Columns 1 through 12
1 1 1 1 2 2 2 2 3 3 3 3
Columns 13 through 16
4 4 4 4
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 =
double
---------------------------------------------------------
如果不想要元胞数组,可以加一句转化一下:
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
for m=1:length(x)
y(m)=x{m}(1)
end
y =
Columns 1 through 12
1 1 1 1 2 2 2 2 3 3 3 3
Columns 13 through 16
4 4 4 4
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询