Plotting multiple graphs on the same plot
2 views (last 30 days)
Show older comments
I need to plot multiple plots on the same graph for different values of z and indicate the maximum value:
For z = 1, 2, 9, 77
y = sin(8*x+pi) + 2*x^2/3 + z*3
How to do that?
0 Comments
Answers (1)
KSSV
on 24 Mar 2022
x = linspace(0,2*pi) ;
z = [1, 2, 9, 77]' ;
y = sin(8*x+pi) + 2*x.^2/3 + 3*z ;
plot(x,y) ;
legend('z=1','z=2','z=9','z=77')
Read about hold on
2 Comments
KSSV
on 24 Mar 2022
You need to transpose y.
x = linspace(-4*g,4*g);
y = [0.01*g 0.2*g 0.6*g g]';
Hx = (1/pi)*(atan(((g/2 + x)./y) + atan((g/2 - x)./y)));
Hy = (-1/2*pi)*(log((g/2 + x).^2 + (y).^2./(g/2 - x).^2 + (y).^2));
plot(x, Hx, '-v', 'LineWidth', 2)
xlabel x1
grid minor
title ('y1 = 0.01*g')
ylabel Hx1
legend('y=0.01g','y = 0.2g','y = 0.6g','y = g')
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!