Reputation: 469
I have nxn matrix in 2D space; I would like to rotate the matrix around the x-axis using matlab. Where the x-axis pass through the center of the matrix (pass through the point [n/2 n/2].
I found the Matlab function B = rot90(A)
which rotate the matrix A by 90 degree. But I’m looking for a method that rotate matrix A by any given angle (e.g. 30, 45, 170 degree) around the x-axis.
Upvotes: 1
Views: 1801
Reputation: 3177
You can as well try imrotate()
. This function is from the Image Processing Toolbox, but since its main input is a matrix (either real or logical) it'll work also for non picture-related matrices (I've tried with a magic
matrix).
The syntax is:
B=imrotate(A,theta);
where A
is you matrix, B
is the rotated version of A
and theta
is the rotation in degrees. The rotation is performed in counterclockwise direction around its center point; to rotate the matrix clockwise, specify a negative value for theta
.
Upvotes: 1