ABSTRACT

MATLAB 7.0 can create compressed MAT-files, so in the future you may need to exclude the .gz extension in this URL. spy plots a sparse matrix (see Section 15.5). 12. Two-Dimensional Graphics MATLAB can produce two-dimensional plots. The primary command for this is plot. Chapter 13 discusses three-dimensional graphics. To preview some of these capabilities, enter the command demo and select some of

the visualization and graphics demos. See Chapter 16 for a discussion of how to plot symbolic functions. Just like any other window, a Figure window can be docked in the main MATLAB window (except on the Macintosh). 12.1 Planar plots The plot command creates linear x-y plots; if x and y are vectors of the same length, the command plot(x,y) opens a graphics window and draws an x-y plot of the elements of y versus the elements of x. You can, for example, draw the graph of the sine function over the interval -4 to 4 with the following commands:

x = -4:0.01:4 ; y = sin(x) ; plot(x, y) ;

Try it. The vector x is a partition of the domain with mesh size 0.01, and y is a vector giving the values of sine at the nodes of this partition (recall that sin operates entry-wise). When plotting a curve, the plot routine is actually connecting consecutive points induced by the partition with line segments. Thus, the mesh size should be chosen sufficiently small to render the appearance of a smooth curve.