reshape - Reshape array maintaining same number of elements

Syntax

reshape(x,[m,n])
reshape(x,[m,n,p...])
reshape(x,[m n p ...])
reshape(x,[...,[],...])

Description

reshape(x,[m,n]) returns the m-by-n array whose elements are taken by column from x. If x does not have m*n elements, reshape returns an error from the operation.

Generally, reshape(x,siz) returns an n-dimensional array with the same elements as x, but reshaped to size(siz). Note that prod(siz) must be the same as prod(size(x)).

reshape(x,[m,n,p...]) returns an n-dimensional array with the same number of elements as x, but reshaped to have size m-by-n-by-p-by-.... For the reshape operation to work, m*n*p*... must equal prod(size(x)).

reshape(x,[m n p ...]) is the same as the preceding syntax.

reshape(x,[...,[],...]) calculates the length of the dimension replaced by [] in the command, so that the product of the dimensions equals prod(size(x)). For the length calculation to succeed, prod(size(x)) must be evenly divisible by the product of the known dimensions (all the dimensions exclusive of the unknown dimension). Within the call, you are allowed to use one set of square brackets for one unknown dimension.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS
 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS