\section{RESHAPE Reshape An Array}

\subsection{Usage}

Reshapes an array from one size to another. Two seperate 
syntaxes are possible.  The first syntax specifies the array 
dimensions as a sequence of scalar dimensions:
\begin{verbatim}
   y = reshape(x,d1,d2,...,dn).
\end{verbatim}
The resulting array has the given dimensions, and is filled with
the contents of \verb|x|.  The type of \verb|y| is the same as \verb|x|.  
The second syntax specifies the array dimensions as a vector,
where each element in the vector specifies a dimension length:
\begin{verbatim}
   y = reshape(x,[d1,d2,...,dn]).
\end{verbatim}
This syntax is more convenient for calling \verb|reshape| using a 
variable for the argument. The
\verb|reshape| function requires that the length of \verb|x| equal the product
of the \verb|di| values.
Note that arrays are stored in column format, 
which means that elements in \verb|x| are transferred to the new array
\verb|y| starting with the first column first element, then proceeding to 
the last element of the first column, then the first element of the
second column, etc.
\subsection{Example}

Here are several examples of the use of \verb|reshape| applied to
various arrays.  The first example reshapes a row vector into a 
matrix.
\begin{verbatim}
--> a = uint8(1:6)

a = 

 1 2 3 4 5 6 

--> reshape(a,2,3)

ans = 

 1 3 5 
 2 4 6 


\end{verbatim}
The second example reshapes a longer row vector into a volume with 
two planes.
\begin{verbatim}
--> a = uint8(1:12)

a = 

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

--> reshape(a,[2,3,2])

ans = 

(:,:,1) = 

  1  3  5 
  2  4  6 

(:,:,2) = 

  7  9 11 
  8 10 12 


\end{verbatim}
The third example reshapes a matrix into another matrix.
\begin{verbatim}
--> a = [1,6,7;3,4,2]

a = 

 1 6 7 
 3 4 2 

--> reshape(a,3,2)

ans = 

 1 4 
 3 7 
 6 2 


\end{verbatim}
