
Department of Engineering 


Next: Plotting experimental data
Up: Graphics
Previous: General
There are many 3D options too, but again you still need to calculate all
the coordinates.
x=linspace(1, 1, 10);
y=linspace(1, 1, 10);
[X, Y]=meshgrid(x,y);
Z= X.^2Y.^2;
mesh(Z);
The meshgrid command creates 2 2D matrices, each with as many
elements as there are gridpoints. The X matrix has the x coordinates and
the Y matrix the y coordinates. Then the z coordinate
is calculated for each point and put in a Z matrix. Instead
of mesh, surf could be used to display a facetted surface.
Then the following can be done to add graduated colour and a key.
shading interp;
colorbar