# reshape

## Purpose

Reshape matrix.

## Synopsis

    B = reshape(A,m,n)

## Description

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

## Examples

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

    A =
        1    4    7    10
        2    5    8    11
        3    6    9    12

    B = reshape(A,2,6)

    B =
        1    3    5    7    9   11
        2    4    6    8   10   12

## Algorithm

MATLAB's colon notation can achieve the same effect, but `reshape` is less cryptic. `reshape` uses the equivalent colon notation:

    B = zeros(m,n);
    B(:) = A;

## See Also

    :, fliplr, flipud, rot90

(c) Copyright 1994 by The MathWorks, Inc.