MATLAB Answers

0

how can i rotate an N-dimensional matrix?

Asked by john creighton on 14 Oct 2014
Latest activity Commented on by Andrei Bobrov
on 15 Oct 2014
hi all i am having trouble with project and need to figure out how i can rotate an N-dimensional matrix so that i can 'look in from the side'. ie rotate the matrix around a virtical axis. see attached image for discription.

  0 Comments

Sign in to comment.

2 Answers

Answer by Andrei Bobrov
on 14 Oct 2014
Edited by Andrei Bobrov
on 15 Oct 2014
 Accepted Answer

A = cat(3,[1 2 3;4 5 6;7 8 9],[10 11 12;13 14 15;16 17 18])
out = permute(A,[3,1,2]);
Please read about function permute.

  2 Comments

thanks Andrei thats exactly what i needed. all i had to do is change [3,1,2] to [1,3,2] :)
Hi John! You wanted following: [3,6,9;12,15,18] and so on, then:
out = flip(permute(A,[3,1,2]),3);

Sign in to comment.


Answer by Adam
on 14 Oct 2014

doc permute
is the n-dimensional equivalent of translation although I'm not 100% sure what you mean by looking at it from the side as that implies you are visualising the matrix in some way.

  1 Comment

hey adam thanks for the quick reply. if i have a 2D matrix of [1 2 3;4 5 6;7 8 9] and a second 2Dmatrix of [10 11 12;13 14 15;16 17 18], i need to be able to view it as another matrix of [3 6 9;12 15 18] and so on...

Sign in to comment.