Concatenating ND matrices using both vertcat and horzcat
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi All, I have a 4x39x7 matrix I wanted a resultant matrix which looks like this:
(1,1,1)(1,2,1)(1,3,1)(1,4,1)...........................(1,39,1) - horzcat of all each of these cells(ex : A1)
(2,1,1)(2,2,1)(2,3,1)(2,4,1)...........................(2,39,1) - horzcat of all each of these cells(ex : A2)
(3,1,1)..........................................................(3,39,1) - horzcat of all each of these cells(ex : A3)
(4,1,1)..........................................................(4,39,1) - horzcat of all each of these cells(ex : A4)
(1,1,2)..........................................................(1,39,2) - horzcat of all each of these cells(ex : A5)
(2,1,2)..........................................................(2,39,2) - horzcat of all each of these cells(ex : A6)
(3,1,2)..........................................................(3,39,2) - horzcat of all each of these cells(ex : A7)
(4,1,2)..........................................................(4,39,2) - horzcat of all each of these cells(ex : A8)
.
.
.
.(4,1,7).........................................................(4,39,7) - horzcat of all each of these cells(ex : A28)
temp = vertcat(A1,A2,.............A28);
So, finally I need to do horizontal concatenation of each of these cells and then vertical concatenation of all the formed cells.
Can anyone help me doing this?
0 comentarios
Respuestas (1)
Walter Roberson
el 1 de Jul. de 2016
It looks to me as if that would just be the following
temp = reshape(YourMatrix, [], size(YourMatrix,2));
with no individual variables or loops required.
2 comentarios
Walter Roberson
el 5 de Jul. de 2016
Editada: Stephen23
el 6 de Jul. de 2016
Could you confirm then that you have a 4x39x7 cell array? If so then what is known about the contents of the cells? Your example with Matrix implies that they might be a single 3D numeric array with 2 pages, but is that always the case? Are the arrays stored in the cell always going to be the same size as each other? Are they always going to be the same data type? Is it certain that there will only be one numeric array in each cell?
Ver también
Categorías
Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!