next up previous
Next: Dressing up your plots Up: Waves Previous: Array calculations

Plots of functions

Plotting arrays of data are easy in MATLAB. Recall one can define 30 points between 0 and 2 tex2html_wrap_inline383 by saying xlist=linspace(0, 2*pi, 30). To plot the sine function between 0 and 2 tex2html_wrap_inline383 one says

ylist=sin(xlist)

then

plot(xlist, ylist).

To plot more functions, keep giving x, y pairs such as

plot(xlist, ylist, xlist, 2*ylist).

Note that we explicitly give MATLAB the x and y values for the plot.

At this point a new window appears on your screen containing the plot. This window will remain open during your session with MATLAB. The MATLAB clf command clears the graphics (figure) window.



VICTOR W SPARROW
Tue Feb 25 21:24:33 EST 1997