I have N^2
3D arrays, all with size (nx, ny, nz)
. These arrays are arranged in a square matrix (N x N). I would like to expand the inner arrays concatenating them along the first two dimensions but not along the third, so the end result should be a matrix with size (N*nx, N*ny, nz)
.
For clarity, you can imagine the following scenario: I collected videos using N^2 cameras arranged in a grid, and now I want to stitch them into a single video.
So for a simple example you can consider I have these 4 arrays
a = rand(1, 2, 3)
b = rand(1, 2, 3)
c = rand(1, 2, 3)
d = rand(1, 2, 3)
and they are arranged as
M = [[a] [b]; [c] [d]]
what I want to do is transform M
into a 3d array V
whose dimensions are (2, 4, 3)
. It should then satisfy
V[1:1, 1:2, :] == M[1,1]
, V[1:1, 3:4, :] == M[1,2]
, V[2:2, 1:2, :] == M[2,1]
, V[2:2, 3:4, :] == M[2,2]
.
It didn’t feel too complicated initially but after trying various combinations of hcat
, vcat
, cat
… I still did not find a simple solution.
Thanks