rot90

Purpose

Rotate matrix 90°.

Synopsis

B = rot90(A)
B = rot90(A,k)

Description

B = rot90(A) rotates the matrix A counterclockwise by 90 degrees.

B = rot90(A,k) rotates the matrix A counterclockwise by k*90 degrees. k must be an integer.

Examples

The matrix

X =
    1    2    3
    4    5    6
    7    8    9
rotated by 90 degrees is

Y = rot90(X)
         
Y =
    3    6    9
    2    5    8
    1    4    7

See Also

fliplr, flipud, reshape

(c) Copyright 1994 by The MathWorks, Inc.