how to rotate a 3d matrix ?

11 views (last 30 days)
Rabih Sokhen
Rabih Sokhen on 19 Sep 2022
Commented: Matt J on 19 Sep 2022
hy guys
i would like to rotate a 3*3 array
suppose i have A=rand(5,4,3)
i would like to rotate it in a way were A now is (4,5,3)
thank you in advance for your help
best regards

Accepted Answer

Matt J
Matt J on 19 Sep 2022
Edited: Matt J on 19 Sep 2022
permute(A,[2,1,3])
or
pagetranspose(A)
  2 Comments
Rabih Sokhen
Rabih Sokhen on 19 Sep 2022
Moved: Matt J on 19 Sep 2022
hy Matt
thank you for your reply
Is there a way to specify which axis I want to permutate with other axis?
Matt J
Matt J on 19 Sep 2022
Yes, the second argument to the permute command lets you specify exactly how you want the axes reordered.

Sign in to comment.

More Answers (1)

Matt J
Matt J on 19 Sep 2022
Edited: Matt J on 19 Sep 2022
A=randi(50,5,4,3)
A =
A(:,:,1) = 20 45 46 13 13 33 29 39 49 39 2 7 19 9 40 20 46 3 17 13 A(:,:,2) = 4 19 6 6 23 29 49 49 36 3 14 48 50 30 34 6 43 1 28 41 A(:,:,3) = 50 14 38 31 16 18 30 3 15 23 7 28 7 14 47 19 19 3 49 3
rot90(A) %or imrotate(A,90)
ans =
ans(:,:,1) = 13 39 7 20 13 46 29 2 40 17 45 33 39 9 3 20 13 49 19 46 ans(:,:,2) = 6 49 48 6 41 6 49 14 34 28 19 29 3 30 1 4 23 36 50 43 ans(:,:,3) = 31 3 28 19 3 38 30 7 47 49 14 18 23 14 3 50 16 15 7 19

Categories

Find more on 3-D Scene Control in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!