\section{NDGRID Generate N-Dimensional Grid}

\subsection{Usage}

Generates N-dimensional grids, each of which is constant in all but
one dimension.  The syntax for its use is either
\begin{verbatim}
   [y1, y2, ..., ym] = ndgrid(x1, x2, ..., xn)
\end{verbatim}
where \verb|m <= n| or 
\begin{verbatim}
   [y1, y2, ..., ym] = ndgrid(x1)
\end{verbatim}
which is equivalent to the first form, with \verb|x1=x2=...=xn|.  Each
output \verb|yi| is an \verb|n|-dimensional array, with values such that
\[
y_i(d_1,\ldots,d_{i-1},d_{i},d_{i+1},\ldots,d_m) = x_i(d_{i})
\]
\verb|ndgrid| is useful for evaluating multivariate functionals over a
range of arguments.  It is a generalization of \verb|meshgrid|, except
that \verb|meshgrid| transposes the dimensions corresponding to the 
first two arguments to better fit graphical applications.
\subsection{Example}

Here is a simple \verb|ndgrid| example
\begin{verbatim}
--> [a,b] = ndgrid(1:2,3:5)
a = 

 1 1 1 
 2 2 2 

b = 

 3 4 5 
 3 4 5 

--> [a,b,c] = ndgrid(1:2,3:5,0:1)
a = 

(:,:,1) = 

 1 1 1 
 2 2 2 

(:,:,2) = 

 1 1 1 
 2 2 2 

b = 

(:,:,1) = 

 3 4 5 
 3 4 5 

(:,:,2) = 

 3 4 5 
 3 4 5 

c = 

(:,:,1) = 

 0 0 0 
 0 0 0 

(:,:,2) = 

 1 1 1 
 1 1 1 


\end{verbatim}
Here we use the second form
\begin{verbatim}
--> [a,b,c] = ndgrid(1:3)
a = 

(:,:,1) = 

 1 1 1 
 2 2 2 
 3 3 3 

(:,:,2) = 

 1 1 1 
 2 2 2 
 3 3 3 

(:,:,3) = 

 1 1 1 
 2 2 2 
 3 3 3 

b = 

(:,:,1) = 

 1 2 3 
 1 2 3 
 1 2 3 

(:,:,2) = 

 1 2 3 
 1 2 3 
 1 2 3 

(:,:,3) = 

 1 2 3 
 1 2 3 
 1 2 3 

c = 

(:,:,1) = 

 1 1 1 
 1 1 1 
 1 1 1 

(:,:,2) = 

 2 2 2 
 2 2 2 
 2 2 2 

(:,:,3) = 

 3 3 3 
 3 3 3 
 3 3 3 


\end{verbatim}
