Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Reshape array

`B = reshape(A,sz)`

`B = reshape(A,sz1,...,szN)`

reshapes `B`

= reshape(`A`

,`sz1,...,szN`

)`A`

into
a `sz1`

-by-`...`

-by-`szN`

array
where `sz1,...,szN`

indicates the size of each dimension.
You can specify a single dimension size of `[]`

to
have the dimension size automatically calculated, such that the number
of elements in `B`

matches the number of elements
in `A`

. For example, if `A`

is a
10-by-10 matrix, then `reshape(A,2,2,[])`

reshapes
the 100 elements of `A`

into a 2-by-2-by-25 array.

Was this topic helpful?