>> plot(xdata,ydata)where xdata and ydata are vectors containing the data. Note that xdata and ydata must be the same length and both must be the same type, i.e., both must be either row or column vectors. Additional arguments to the plot command provide other options including the ability to plot multiple data sets, and a choice of colors, symbols and line types for the data.
>> x = 0:pi/30:2*pi; % x vector, 0 <= x <= 2*pi, increments of pi/30 >> y = sin(3*x); % vector of y values >> plot(x,y) % create the plot >> xlabel('x (radians)'); % label the x-axis >> ylabel('sine function'); % label the y-axis >> title('sin(3*x)'); % put a title on the plot
The effect of the labeling commands, xlabel, ylabel, and title are indicated by the text and red arrows in the figure. Don't skimp on the labels!
Command Name | Plot type |
---|---|
loglog | log(y) versus log(x) |
semilogx | y versus log(x) |
semilogy | log(y) versus x |
[Preceding Section] [Master Outline] [Section Outline] [Next Section]