MATLAB Function Reference
  Go to function:
    Search    Help Desk 
reshape    Examples   See Also

Reshape array

Syntax

Description

B = reshape(A,m,n) returns the m-by-n matrix B whose elements are taken column-wise from A. An error results if A does not have m*n elements.

B = reshape(A,m,n,p,...) or B = reshape(A,[m n p...]) returns an N-D array with the same elements as X but reshaped to have the size m-by-n-by-p-by-... . m*n*p*... must be the same as prod(size(x)).

B = reshape(A,siz) returns an N-D array with the same elements as A, but reshaped to siz, a vector representing the dimensions of the reshaped array. The quantity prod(siz) must be the same as prod(size(A)).

Examples

Reshape a 3-by-4 matrix into a 2-by-6 matrix:

See Also

: (colon)   Colon :

shiftdim    Shift dimensions

squeeze      Remove singleton dimensions



[ Previous | Help Desk | Next ]