3. 2016.9.12 Matlab Matrix Rotate

3.1. Situation:

  • I was using Matlab’s function bar3, and struggled to get the right order of input matrix.

3.2. Solution:

Matlab has provided several functions itself : rot90(X,n), fliplr(X), flipud(X), flipdim(X,dim)

  1. rot90(X,n) can rotate a matrix conterclockwise
    • Usage:
      • X : Target Matrix
      • n : Time you rotate 90 degree, eg. 3 rotate 270 degree
  2. fliplr(X) can flip a matrix horizontally
  3. flipud(X) can flip a matrix upside down
  4. flipdim(X,dim) can flip a matrix with specific method
    • Usage:
      • flipdim(A,1) is equivalent to flipud(A)
      • flipdim(A,2) is equivalent to fliplr(A)