MATLAB Examples

Plot Multiple Lines

This example shows how to plot more than one line by passing multiple x,y pairs to the plot function.

Define y1 and y2 as sine waves with a phase shift.

x = linspace(0,2*pi,100);
y1 = sin(x);
y2 = sin(x-pi/4);

Plot the lines.

figure
plot(x,y1,x,y2)

plot cycles through a predefined list of line colors.