我有一个大小< 1x12582 cell>的行向量,我想将它与自身结合起来得到结果< 1x25164 cell>。例如:
cellint = {'gene1','gene2','gene3','gene4'};
cellout = {'gene1','gene2','gene3','gene4','gene1','gene2','gene3','gene4'};
我已尝试horzcat
如下,但它没有给出正确的结果:
SS = [cellint;cellint];
答案 0 :(得分:1)
Horizontal concatenation(即沿第二个(列)维度的连接)在方括号内使用空格或逗号:
cellout = [cellint cellint]; % or ...
cellout = [cellint, cellint]; % or ...
% Functional equivalents:
cellout = horzcat(cellint, cellint); % or ...
cellout = cat(2, cellint, cellint);
Vertical concatenation(即沿第一个(行)维度的连接)在方括号内使用分号:
cellout = [cellint; cellint]; % or ...
% Functional equivalents:
cellout = vertcat(cellint, cellint); % or ...
cellout = cat(1, cellint, cellint);
对于沿任意维度的连接(如上面每个示例的最后一行所示),使用函数cat
:
cellout = cat(3, cellint, cellint); % Would concatenate along the third dimension