Contents Previous Next Subchapters

Rotate A Matrix By a Multiple of 90 Degrees
Syntax rot90(xn)
See Also flipud , fliplr , transpose

Description
Rotates the matrix x by n times 90 degrees in the counterclockwise direction where n is a scalar and equal to an integer. The default value for n is one.

A single rotation by 90 degrees is the same as reversing the order of the elements in each row and then transposing the matrix; i.e.,
     rot90(x) = x(end : -1 : 1, :)'


Values of n greater than zero result in the specified number of rotations by 90 degrees. Values of n less than zero correspond to the inverse mapping for the corresponding absolute value of n.

Example
If you enter
     x = { ...
          [ 5 , 3 , 1 ], ...
          [ 6 , 4 , 2 ] ...
     }
     rot90(x)
O-Matrix will respond
     {
     [ 1 , 2 ], ... 
     [ 3 , 4 ], ... 
     [ 5 , 6 ] ... 
     }