How do I concatenate 2 cell arrays?

4 Ansichten (letzte 30 Tage)
Cai Chin
Cai Chin am 27 Dez. 2020
Beantwortet: Walter Roberson am 27 Dez. 2020
Hi, I am attempting to concatenate 2 cell arrays such that the dimensions of the concatenated cell array are 2215 x 1, with each cell containing a 2 x 900 double. Each of the component cell arrays ahs dimensions of 2215 x 1 with each cell containing a 1 x 900 double. Any suggestions would be greatly appreciated, thanks in advance.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 27 Dez. 2020
FirstCell = num2cell(randi(9, 15, 9), 2);
SecondCell = num2cell(randi(9, 15, 9), 2);
size(FirstCell)
ans = 1×2
15 1
size(FirstCell{1})
ans = 1×2
1 9
output = cellfun(@(a,b) [a;b], FirstCell, SecondCell, 'uniform', 0);
size(output)
ans = 1×2
15 1
size(output{1})
ans = 1×2
2 9

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by