Matlab怎样合并cell类型的数组和double类型数组

 我来答
可爱小不点year
2017-09-02 · TA获得超过803个赞
知道小有建树答主
回答量:859
采纳率:89%
帮助的人:808万
展开全部
元胞数组的元素都是矩阵呀,转化完后也是矩阵
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
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式