
Creating Mesh and Surface Plots
Creating Mesh and Surface Plots
In this section.. .
“About Mesh and Surface Plots” on page 3-63
“Visualizing Functions of Two Va riables” on p age 3-63
AboutMeshandSurfacePlots
MATLAB defines a surface by the z-coo rdinate s of points abov e a grid in the
x-y plane, using straight lines to connect adjacent points. The
mesh and
surf plotting functions display surfaces in three dimensions. mesh produces
wireframe surfaces that color only the lines connecting the defining points.
surf displays both the connecting lines and the faces of the surface in color.
The figure colormap and figure properties determine how MATLAB colors
the surface.
Visualizing Functions of Two Variables
To dis play a function of two variables, z = f (x,y),
1 Generate X and Y matrices consisting of repeated row s and columns,
respectively, over the domain of the function.
2 Use X and Y to evaluate and graph the function.
The
meshgrid function transforms the domain specified by a single vector or
two vectors
x and y into matrices X and Y for use in evaluating functions of
two variables. The rows of
X are copies of the vector x and the columns of
Y are copies of the vector y.
Example — Graphing the sinc Function
This example evaluates and graphs the two-dimensional sinc function,
sin(r)/r, between the x and y directions.
R is the distance from the origin, which
is at the center of the matrix. A dding
eps (a MATLAB command that returns
a small floating-point number) avoids the indeterminate 0/0 at the origin:
[X,Y] = meshgrid(-8:.5:8);
3-63
Comentários a estes Manuais