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?
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 .
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].
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With