I work using Matlab and I have a matrix in 400x400x3x3 shape. I need to reshape it into 1200x1200. How do I do that?
I know there's a command called reshape and I've tried using it, but I'm missing something that I'm not seeing it.
I work using Matlab and I have a matrix in 400x400x3x3 shape. I need to reshape it into 1200x1200. How do I do that?
I know there's a command called reshape and I've tried using it, but I'm missing something that I'm not seeing it.
I'm going to guess that you want dimensions 1 and 3 to collapse into a new first dimension, and dimensions 2 and 4 to collapse into a new second dimension.
In that case, you need permute before reshape so that the dimensions to be collapsed appear together:
x = rand(400, 400, 3, 3); % random data
y = reshape(permute(x, [1 3 2 4]), size(x,1)*size(x,3), size(x,2)*size(x,4));
x = randn(400,400,3,3);
xr = reshape(x,1200,1200);
For an official reference, nomen omen. This is the most straightforward answer, but actually there are different approaches depending on how you want to structure your data.