Contents Previous Next Subchapters Current Chapters-> align atod atoi char2dbl ntoa num2str str2num strreplace strclip clipstr low2up up2low dquote file2str pack unpack char2id reprow str2strdir sort sort3 psort psort3 mlmode_sort reverse flipud fliplr rot90 nonzeros find find2 find3 dec2hex hex2dec findstr whichrow Parent Chapters-> Omatrix6 stringssort rot90 Search Tools-> contents reference index search

Rotate A Matrix By a Multiple of 90 Degrees
 Syntax `rot90(`x`, `n`)` 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 ] ...       } ```