rot90
Rotate a matrix 90 degrees counter-clockwise.
Syntax
Section titled “Syntax”B = rot90(A)B = rot90(A, k)Description
Section titled “Description”Rotates A by 90° counter-clockwise. With the optional integer k, rotates by k * 90° (negative k rotates clockwise). Equivalent to applying flipud(A') for k=1, flipud(fliplr(A)) for k=2, etc.
Examples
Section titled “Examples”rot90([1 2; 3 4]) % [2 4; 1 3]rot90([1 2; 3 4], 2) % [4 3; 2 1]rot90([1 2; 3 4], -1) % [3 1; 4 2]