Page 32 -
P. 32
in the x-direction, assuming that the z-parametric equation remains the same,
show the resulting 3-D trajectory.
Pb. 1.12 What if z(t) is periodic in t? For example, z(t) = cos(t) or z(t) =
cos(2t), while the 2-D motion is still circular. Show the 3-D trajectory.
In Example 1.14, we used the for loop to generate the dependent arrays for
the helix; but as pointed out previously, a more efficient method to program
the helix is in the array notation, as follows:
th=[0:.01:2]*2*pi;
x=cos(th);
y=sin(th);
z=th;
plot3(x,y,z)
1.7.4 Plotting a 3-D Surface
We now explore the two different techniques for rendering, in MATLAB, 3-D
surface graphics: the mesh and the contour representations.
• A function of two variables z = f(x, y) represents a surface in 3-D
geometry; for example:
z = ax + by + c
represents a plane that crosses the vertical axis (z-axis) at c.
• There are essentially two main techniques in MATLAB for viewing
surfaces: the mesh function and the contour function.
• In both techniques, we must first create a 2-D array structure (like
a checkerboard) with the appropriate x- and y-values. To imple-
ment this, we use the MATLAB meshgrid function.
• The z-component is then expressed in the variables assigned to
implement the meshgrid command.
• We then plot the function with either the mesh command or the
contour command. The mesh command gives a 3-D rendering of
the surface, while the contour command gives contour lines,
wherein each contour represents the locus of points on the surface
having the same height above the x-y plane. This last rendering
technique is that used by mapmakers to represent the topography
of a terrain.
© 2001 by CRC Press LLC