How to indicate the maximum value on the given curve
z1 = [0.00008 0.009]';
a11 = -1:0.001:1;
k1 = atan(((0.01/2 + a11)./z1)) + atan((0.01/2 - a11)./z1);
plot(a11,k1(1,:),'-k',a11,k1(2,:),'-r')

 채택된 답변

Davide Masiello
Davide Masiello 2022년 4월 14일
편집: Davide Masiello 2022년 4월 14일

1 개 추천

z1 = [0.00008 0.009]';
a11 = -1:0.001:1;
k1 = atan(((0.01/2 + a11)./z1)) + atan((0.01/2 - a11)./z1);
[~,idx_k1] = max(k1,[],2);
plot(a11,k1(1,:),'-k',a11,k1(2,:),'-r',a11(idx_k1(1)),k1(1,idx_k1(1)),'*b',a11(idx_k1(2)),k1(2,idx_k1(2)),'*b')
text(a11(idx_k1(1))+0.05,k1(1,idx_k1(1)),num2str(k1(1,idx_k1(1))))
text(a11(idx_k1(2))+0.05,k1(2,idx_k1(2)),num2str(k1(2,idx_k1(2))))

댓글 수: 4

Amy Topaz
Amy Topaz 2022년 4월 14일
Thank you,
Also How to indicate the numerical value at the top of the curve?
Davide Masiello
Davide Masiello 2022년 4월 14일
Edited the code, now it does that too.
If correct, please accept the answer for reference to other users with the same problem.
Sam Chak
Sam Chak 2022년 4월 14일
+1.
Another way to plot a marker at the maximum point, assuming you don't want any other markers, is to use the MarkerIndices property of the line.
x = 0:180;
s = sind(x);
[~, location] = max(s);
plot(x, s, 'o-', 'MarkerIndices', location, ...
'MarkerFaceColor', 'r') % Make the marker stand out in red

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

질문:

2022년 4월 14일

댓글:

2022년 4월 14일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by