single plot command to plot 3 curves versus x in matlab

To plot 3 curves versus x in a single command in MATLAB, you can use the plot command with multiple inputs:

main.m
x = linspace(0, 2*pi); % create a vector of x values
y1 = sin(x);
y2 = cos(x);
y3 = tan(x);
plot(x, y1, x, y2, x, y3)
legend('sin(x)', 'cos(x)', 'tan(x)')
155 chars
7 lines

This code will generate a single plot with each curve in a different color, and a legend identifying each curve. You can adjust the line styles and colors by passing additional arguments to the plot command, as described in the MATLAB documentation.

gistlibby LogSnag