1
votes

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.

3
HOW do you want to reshape it? (400x3) x (400x3) has two options - bla

3 Answers

2
votes

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));
0
votes
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.

-1
votes

Not sure what you are missing. Please provide more information.

From what you have said so far, it's just

reshapedA=reshape(A, [1200,1200]);