Concatenating ND matrices using both vertcat and horzcat
3 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Walter Roberson
on 1 Jul 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 Comments
Walter Roberson
on 5 Jul 2016
Edited: Stephen23
on 6 Jul 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?
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!