MATLAB Answers

Converting a matrix of other forms into one simple matrix - help

1 view (last 30 days)
Itachi
Itachi on 11 Sep 2012
Hi guys, I have 4x36x4 matrix and I wanted to make it into 16x36 matrix, is there anyway to do that?
Best regards, Ayubirad

  0 Comments

Sign in to comment.

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 11 Sep 2012
Edited: Andrei Bobrov on 11 Sep 2012
please read about the function reshape
A = randi(456,4,36,4); % Let the initial array
out = reshape(A,16,[]);
ADD (please read about the function permute)
out = reshape(reshape(A,size(A,1),[])',size(A,2),[])';
or
out = reshape(permute(A,[2 1 3]),size(A,2),[])';

  3 Comments

Itachi
Itachi on 11 Sep 2012
Thanks, but when I do that the order of elements in rows and columns won't be the same! I want to keep the order. reshape does column-wise but I want sth like squeeze. The data arrangement is important.
Best regards,

Sign in to comment.

More Answers (0)

Sign in to answer this question.


Translated by