Plotting multiple graphs on the same plot
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
KSSV
am 24 Mär. 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 Kommentare
KSSV
am 24 Mär. 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')
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!