Answer on Question #52172, Programming, Mat LAB | Mathematica | MathCAD | Maple
Create a 2D graph by plotting multiple data series on the same axes, using a resolution of at least 0.1 between points. Choose your axis limits so that all three mathematical functions show at least 2 full iterations. Ensure axes are all labelled, and each data series has a different line style, marker and colour.
y = f(x) = sin(x)
y = f(x) = cos(x)
y = f(x) = tan(x)Solution:
x = 0:pi/50:4*pi;
y1 = sin(x);
plot(x, y1, 'b-*');
hold on
ylim manual
y2 = cos(x);
hold on
plot(x, y2, 'r-');
y3 = tan(x);
hold on
plot(x, y3, 'go');
ylim([-2 2]) %set the y-axis limits to range from -2 to 2.
hold off
legend('sin(x)', 'cos(x)', 'tan(x)');
xlabel('x');
ylabel('y');
Comments