rot90
Returns R, the result of rotating matrix, m, in 90-degree succession(s).
Syntax
R = rot90(m)
R = rot90(m, n)
Inputs
- m
- Type: matrix
- n (optional)
- Specifies the number of 90-degree rotations which need to be performed on m. If n is not specified or is positive, rotations will be in the counterclockwise direction. A negative value of n results in clockwise rotations.
Outputs
- R
- Type: matrix
Examples
Default 90-degree counterclockwise rotation:
R = rot90([1,2,3,4;5,6,7,8;9,10,11,12])
R = [Matrix] 4 x 3
4 8 12
3 7 11
2 6 10
1 5 9
Two 90-degree counterclockwise rotations:
R = rot90([1,2,3,4;5,6,7,8;9,10,11,12], 2)
R = [Matrix] 3 x 4
12 11 10 9
8 7 6 5
4 3 2 1
90-degree clockwise rotation:
R = rot90([1,2,3,4;5,6,7,8;9,10,11,12], -1)
R = [Matrix] 4 x 3
9 5 1
10 6 2
11 7 3
12 8 4