shay
shay

Reputation: 331

Reshaping a 3 dimensional array to 2 dimensions

I have a 3-dimensional matrix of dimensions: 427x470x48

I want to reshape this into a 2-dimensional matrix of dimensions: 48x200690

This would mean that old(1, 1, :) would correspond to new(:, 1)

Additionally, old(1,2,:) would correspond to new(:,2) and so on and so forth.

Thank You

Upvotes: 2

Views: 2597

Answers (1)

voxeloctree
voxeloctree

Reputation: 849

Do:

new = reshape(permute(old, [3 2 1]), 48, []);

Also you can roughly check that they are equal by:

numel(intersect(old(1,1,:),new(:,1))) == 48;

Upvotes: 3

Related Questions