Programming Previous page   Next Page

Reshaping a Matrix

The following functions change the shape of a matrix.

Function
Description
reshape
Modify the shape of a matrix.
rot90
Rotate the matrix by 90 degrees.
fliplr
Flip the matrix about a vertical axis.
flipud
Flip the matrix about a horizontal axis.
flipdim
Flip the matrix along the specified direction.
transpose
Flip a matrix about its main diagonal, turning row vectors into column vectors and vice versa.
ctranspose
Transpose a matrix and replace each element with its complex conjugate.

Examples

Here are a few examples to illustrate some of the ways you can reshape matrices.

Reshaping a Matrix.   Reshape 3-by-4 matrix A to have dimensions 2-by-6:

Transposing a Matrix.   Transpose A so that the row elements become columns. You can use either the transpose function or the transpose operator (.') to do this:

There is a separate function called ctranspose that performs a complex conjugate transpose of a matrix. The equivalent operator for ctranpose on a matrix A is A':

Rotating a Matrix.   Rotate the matrix by 90 degrees:

Flipping a Matrix.   Flip A in a left-to-right direction:


Previous page  Diminishing the Size of a Matrix Preallocating Memory Next page

© 1994-2005 The MathWorks, Inc.