plot multiple functions in the same graph in matlab in matlab

main.m
% Define the range of x values
x = -2*pi:0.1:2*pi;

% Define the functions to plot
y1 = sin(x);
y2 = cos(x);
y3 = tan(x);

% Plot all the functions in the same graph
hold on
plot(x, y1)
plot(x, y2)
plot(x, y3)
legend('sin(x)', 'cos(x)', 'tan(x)')
hold off
256 chars
16 lines

related categories

gistlibby LogSnag