how to rotate a 3d matrix ?

14 次查看(过去 30 天)
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

采纳的回答

Matt J
Matt J 2022-9-19
编辑:Matt J 2022-9-19
permute(A,[2,1,3])
or
pagetranspose(A)
  2 个评论
Rabih Sokhen
Rabih Sokhen 2022-9-19
移动:Matt J 2022-9-19
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 2022-9-19
Yes, the second argument to the permute command lets you specify exactly how you want the axes reordered.

请先登录,再进行评论。

更多回答(1 个)

Matt J
Matt J 2022-9-19
编辑:Matt J 2022-9-19
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

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by