如何在matlab中连接两个单元格数组 [英] How to concatenate two cell arrays in matlab
问题描述
我有数组
A = cell(4,1);
A = [1; 2; 3; 4];
我必须增加A的大小,即以8为例。当我填充零或简单地垂直连接两个数组(一个是A和其他只是例如B =单元格(4,1))
我得到答案像
[4x1双]
[]
[]
[]
[]
而我需要输出像
1
2
3
4
[]
[]
[]
[]
或者如果填充零,那么
1
2
3
4
0
0
0
0
plz帮助我因为我需要这个紧急 ..我已经尝试了很多..当矩阵只是一个数组而不是一个单元数组时,它可以工作..但在我的情况下,我需要这个用于单元数组
I have array as
A=cell(4,1);
A=[1;2;3;4];
i have to increase the size of A. i.e to make it 8 for example. when i pad the zeros or simply vertically concatenate the two array(one is A and other is simply e.g B=cell(4,1))
I get the answer like
[4x1 double]
[]
[]
[]
[]
whereas i need output like
1
2
3
4
[]
[]
[]
[]
or if padding zeros then
1
2
3
4
0
0
0
0
plz help me as i need this urgent.. i have tried alot..it works when A matrix is simply an array not a cell array..but in my case i need this for cell array
推荐答案
如果你有两个数组A和B然后你可以使用命令 cat(1,A,B)获得结果数组。
根据函数第一个参数的值,内部matlab将调用vertcat或horzcat
Well if you have two arrays A and B then you can get the resulting array using the command cat(1, A,B).
Based on the value of the first parameter of the function, internally matlab will call vertcat or horzcat
这篇关于如何在matlab中连接两个单元格数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!