Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rotating a 3D matrix in MATLAB

Tags:

matrix

matlab

I have a 3D matrix with the dimensions 6, 2, and 10. I want the row dimension to switch places with the height dimension, that is, 10-2-6. reshape doesn't achieve this the way I want.

How can this be done? Can I rotate the matrix?

like image 934
Eduardas Avatar asked Oct 26 '10 15:10

Eduardas


People also ask

How do you create a 3d rotation matrix in Matlab?

Description. R = rotx( ang ) creates a 3-by-3 matrix for rotating a 3-by-1 vector or 3-by-N matrix of vectors around the x-axis by ang degrees. When acting on a matrix, each column of the matrix represents a different vector. For the rotation matrix R and vector v , the rotated vector is given by R*v .

How do you rotate a 3d object in Matlab?

Answers (1)rotate(h,direction,alpha) -rotate object about specified origin and direction. rotate(...,origin) - specifies the origin of the axis of rotation as a three-element vector [x0,y0,z0].

How do you rotate a matrix in Matlab?

B = rot90( A ) rotates array A counterclockwise by 90 degrees. For multidimensional arrays, rot90 rotates in the plane formed by the first and second dimensions. B = rot90( A , k ) rotates array A counterclockwise by k*90 degrees, where k is an integer.

What is 3d rotation matrix?

The most general three-dimensional rotation matrix represents a counterclockwise rotation by an angle θ about a fixed axis that lies along the unit vector n. The rotation matrix operates on vectors to produce rotated vectors, while the coordinate axes are held fixed.


1 Answers

I think you're looking for permute. For your case it's, permute(A,[3 2 1]);. Here's a description of permute from the documentation:

B = permute(A,order) rearranges the dimensions of A so that they are in the order specified by the vector order. B has the same values of A but the order of the subscripts needed to access any particular element is rearranged as specified by order. All the elements of order must be unique.the elements of order must be unique.

It's similar to transposing a 2D matrix.

like image 90
Jacob Avatar answered Sep 28 '22 13:09

Jacob