\section{MESHGRID Generate Grid Mesh For Plots}

\subsection{Usage}

The \verb|meshgrid| function generates arrays that can be used for the
generation of surface plots.  The syntax is one of 
\begin{verbatim}
  [X,Y] = meshgrid(x)
  [X,Y] = meshgrid(x,y)
  [X,Y,Z] = meshgrid(x,y,z)
\end{verbatim}
where \verb|x,y,z| are vectors, and \verb|X,Y,Z| are matrices.  In the first
case \verb|[X,Y] = meshgrid(x)|, the rows of \verb|X| and the columns of \verb|Y|
contain copies of the vector \verb|x|.  In the second case 
\verb|[X,Y] = meshgrid(x,y)|, the rows of \verb|X| contain copies of \verb|x|, and
the columns of \verb|Y| contain copies of \verb|y|.  In the third case, each
input is copied along the row, column or slice direction of the
corresponding output variable.
\subsection{Example}

In the first example:
\begin{verbatim}
--> [X,Y] = meshgrid(-2:.4:2)
X = 
 
Columns 1 to 10

   -2.0000   -1.6000   -1.2000   -0.8000   -0.4000   -0.0000    0.4000    0.8000    1.2000    1.6000 
   -2.0000   -1.6000   -1.2000   -0.8000   -0.4000   -0.0000    0.4000    0.8000    1.2000    1.6000 
   -2.0000   -1.6000   -1.2000   -0.8000   -0.4000   -0.0000    0.4000    0.8000    1.2000    1.6000 
   -2.0000   -1.6000   -1.2000   -0.8000   -0.4000   -0.0000    0.4000    0.8000    1.2000    1.6000 
   -2.0000   -1.6000   -1.2000   -0.8000   -0.4000   -0.0000    0.4000    0.8000    1.2000    1.6000 
   -2.0000   -1.6000   -1.2000   -0.8000   -0.4000   -0.0000    0.4000    0.8000    1.2000    1.6000 
   -2.0000   -1.6000   -1.2000   -0.8000   -0.4000   -0.0000    0.4000    0.8000    1.2000    1.6000 
   -2.0000   -1.6000   -1.2000   -0.8000   -0.4000   -0.0000    0.4000    0.8000    1.2000    1.6000 
   -2.0000   -1.6000   -1.2000   -0.8000   -0.4000   -0.0000    0.4000    0.8000    1.2000    1.6000 
   -2.0000   -1.6000   -1.2000   -0.8000   -0.4000   -0.0000    0.4000    0.8000    1.2000    1.6000 
   -2.0000   -1.6000   -1.2000   -0.8000   -0.4000   -0.0000    0.4000    0.8000    1.2000    1.6000 
 
Columns 11 to 11

    2.0000 
    2.0000 
    2.0000 
    2.0000 
    2.0000 
    2.0000 
    2.0000 
    2.0000 
    2.0000 
    2.0000 
    2.0000 

Y = 
 
Columns 1 to 10

   -2.0000   -2.0000   -2.0000   -2.0000   -2.0000   -2.0000   -2.0000   -2.0000   -2.0000   -2.0000 
   -1.6000   -1.6000   -1.6000   -1.6000   -1.6000   -1.6000   -1.6000   -1.6000   -1.6000   -1.6000 
   -1.2000   -1.2000   -1.2000   -1.2000   -1.2000   -1.2000   -1.2000   -1.2000   -1.2000   -1.2000 
   -0.8000   -0.8000   -0.8000   -0.8000   -0.8000   -0.8000   -0.8000   -0.8000   -0.8000   -0.8000 
   -0.4000   -0.4000   -0.4000   -0.4000   -0.4000   -0.4000   -0.4000   -0.4000   -0.4000   -0.4000 
   -0.0000   -0.0000   -0.0000   -0.0000   -0.0000   -0.0000   -0.0000   -0.0000   -0.0000   -0.0000 
    0.4000    0.4000    0.4000    0.4000    0.4000    0.4000    0.4000    0.4000    0.4000    0.4000 
    0.8000    0.8000    0.8000    0.8000    0.8000    0.8000    0.8000    0.8000    0.8000    0.8000 
    1.2000    1.2000    1.2000    1.2000    1.2000    1.2000    1.2000    1.2000    1.2000    1.2000 
    1.6000    1.6000    1.6000    1.6000    1.6000    1.6000    1.6000    1.6000    1.6000    1.6000 
    2.0000    2.0000    2.0000    2.0000    2.0000    2.0000    2.0000    2.0000    2.0000    2.0000 
 
Columns 11 to 11

   -2.0000 
   -1.6000 
   -1.2000 
   -0.8000 
   -0.4000 
   -0.0000 
    0.4000 
    0.8000 
    1.2000 
    1.6000 
    2.0000 


\end{verbatim}
Next, we use different vectors for \verb|X| and for \verb|Y|:
\begin{verbatim}
--> [X,Y] = meshgrid([1,2,3,4],[6,7,8])
X = 

 1 2 3 4 
 1 2 3 4 
 1 2 3 4 

Y = 

 6 6 6 6 
 7 7 7 7 
 8 8 8 8 


\end{verbatim}
