Plotting multiple graphs on the same plot
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (1개)
KSSV
2022년 3월 24일
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
KSSV
2022년 3월 24일
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')
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!