02.03.2016 Views

MATLAB by rudra pratap

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

190<br />

Graphics<br />

cylinder<br />

generates a cylinder,<br />

ellipsoid<br />

generates an ellipsoid, and<br />

sphere<br />

generates a sphere.<br />

Among these functions, plot3 and comet3 are the 3-D analogs of plot and<br />

comet commands mentioned in the 2-D graphics section. The general syntax for<br />

the plot3 command is<br />

'I__ p_l_o_t_3_(_x_,---,-z-,--,-s-t_ y y _l_e __ o_ _t_i_o_n-' )---,<br />

p<br />

This command plots a curve in 3-D space with the specified line style. The argument<br />

list can be repeated to make overlay plots, just the same way as with the plot<br />

command. A catalog of these functions with example scripts and the corresponding<br />

output is given on pages 196-200. Because the example scripts use a few functions<br />

that we discuss in Section 6.3.3, we postpone the catalog until then.<br />

Plots in 3-D may be annotated with functions already mentioned for 2-D plotsxlabel,<br />

ylabel, title, text , grid, etc., along with the obvious addition of<br />

zlabel. The grid command in 3-D makes the 3-D appearance of the plots better,<br />

especially for curves in space (see Fig. 6.5 for example).<br />

6.3.1 View<br />

The viewing angle of the observer is specified <strong>by</strong> the command<br />

I view (azimuth, elevation)<br />

where azimuth and elevation are angles specified in degrees. The azimuth is the rotation<br />

about the z-axis measured counterclockwise from the negative y-axis, and the<br />

elevation is the vertical angle measured positive above the xy-plane (see Fig. 6.4).<br />

The default values for these angles are -37.5° and 30° , respectively.<br />

I<br />

Figure 6.4: The viewing angles azimuth and elevation in 3-D plots.<br />

By specifying appropriate values of the azimuth and the elevation, one can plot<br />

the projections of a 3-D object on different 2-D planes. For example, the command<br />

view(90 ,0) puts the viewer on the positive x-axis, looking straight on the yz-plane,<br />

and thus produces a 2-D projection of the object on the yz-plane. Figure 6.5 shows<br />

the projections obtained <strong>by</strong> specifying different view angles.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!