Page 33 -
P. 33

1.7.4.1  Surface Rendering
                             Example 1.15
                             Plot the sinc function whose equation is given by:

                                                             (  x + )
                                                                2
                                                                    2
                                                          sin      y
                                                       z =
                                                             x +  y  2
                                                               2
                             over the domain –8 < x < 8 and –8 < y < 8.

                             Solution: The implementation of the mesh rendering follows:

                                x=[-8:.1:8];
                                y=[-8:.1:8];
                                [X,Y]=meshgrid(x,y);
                                R=sqrt(X.^2+Y.^2)+eps;
                                Z=sin(R)./R;
                                mesh(X,Y,Z)

                             The variable eps is a tolerance number = 2  used for determining expres-
                                                                   –52
                             sions near apparent singularities, to avoid numerical division by zero.
                              To generate a contour plot, we replace the last command in the above by:


                                contour(X,Y,Z,50) % The fourth argument specifies
                                   % the number of contour lines to be shown


                             If we are interested only in a particular contour level, for example, the one
                             with elevation Z , we use the contour function with an option, as follows:
                                           0

                                contour(X,Y,Z,[Z  Z ])
                                                       o
                                                   o
                              Occasionally, we might be interested in displaying simultaneously the
                             mesh and contour rendering of a surface. This is possible through the use of
                             the command meshc. It is the same as the mesh command except that a
                             contour plot is drawn beneath the mesh.

                             Preparatory Activity: Look in your calculus book for some surfaces equations,
                             such as those of the hyperbolic paraboloid and the elliptic paraboloid and
                             others of your choice for the purpose of completing Pb. 1.16 of the next in-
                             class activity.




                             © 2001 by CRC Press LLC
   28   29   30   31   32   33   34   35   36   37   38