\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 = 
  <int32>  - size: [2 3]
 
Columns 1 to 3
 1  1  1  
 2  2  2  
b = 
  <int32>  - size: [2 3]
 
Columns 1 to 3
 3  4  5  
 3  4  5  
--> [a,b,c] = ndgrid(1:2,3:5,0:1)
a = 
  <int32>  - size: [2 3 2]
(:,:,1) = 
 
Columns 1 to 3
 1  1  1  
 2  2  2  
(:,:,2) = 
 
Columns 1 to 3
 1  1  1  
 2  2  2  
b = 
  <int32>  - size: [2 3 2]
(:,:,1) = 
 
Columns 1 to 3
 3  4  5  
 3  4  5  
(:,:,2) = 
 
Columns 1 to 3
 3  4  5  
 3  4  5  
c = 
  <int32>  - size: [2 3 2]
(:,:,1) = 
 
Columns 1 to 3
 0  0  0  
 0  0  0  
(:,:,2) = 
 
Columns 1 to 3
 1  1  1  
 1  1  1  

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

\end{verbatim}
