Getting Started Previous page   Next Page

Creating a Plot

The plot function has different forms, depending on the input arguments. If y is a vector, plot(y) produces a piecewise linear graph of the elements of y versus the index of the elements of y. If you specify two vectors as arguments, plot(x,y) produces a graph of y versus x.

For example, these statements use the colon operator to create a vector of x values ranging from 0 to 2pi, compute the sine of these values, and plot the result:

Now label the axes and add a title. The characters \pi create the symbol pi. See text strings for more symbols:


Previous page  Basic Plotting Functions Multiple Data Sets in One Graph Next page

© 1994-2005 The MathWorks, Inc.