Concatenating ND matrices using both vertcat and horzcat
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Walter Roberson
2016-7-1
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 个评论
Walter Roberson
2016-7-5
编辑:Stephen23
2016-7-6
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?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!