3D Plots
After having made a grid you can plot a 3D graph using the command
mesh(xx,yy,z)
where xx and yy are the matrices made by meshgrid
and where z is a function of x and y. You get
the function values of z by using element by element operations on
matrices xx and yy.

>>> x=linspace(-2,2,5); >>> y=linspace(-2,2,5); >>> [xx,yy]=meshgrid(x,y); >>> mesh(xx,yy,4-(xx.^2+yy.^2))
If you want a smoother graph, make a longer x-vector and a longer y-vector.

>>> x=linspace(-2,2,50); >>> y=linspace(-2,2,50); >>> [xx,yy]=meshgrid(x,y); >>> mesh(xx,yy,4-(xx.^2+yy.^2))
You can get a contour plot by using the command meshc.

>>> x=linspace(-2,2,50); >>> y=linspace(-2,2,50); >>> [xx,yy]=meshgrid(x,y); >>> meshc(xx,yy,4-(xx.^2+yy.^2))
by Malin Christersson under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 Sweden License