Graphics    

Creating Line Plots

The plot function has different forms depending on the input arguments. For example, if y is a vector, plot(y) produces a 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 create a vector of values in the range [0, 2] in increments of /100 and then use this vector to evaluate the sine function over that range. MATLAB plots the vector on the x-axis and the value of the sine function on the y-axis.

MATLAB automatically selects appropriate axis ranges and tick mark locations.

You can plot multiple graphs in one call to plot using x-y pairs. MATLAB automatically cycles through a predefined list of colors to allow discrimination between each set of data. Plotting three curves as a function of t produces


  Basic Plotting Commands Specifying Line Style