Mark max value and min value with red circle

조회 수: 46 (최근 30일)
Mathias Pettersen
Mathias Pettersen 2019년 9월 23일
댓글: dpb 2021년 5월 17일
Hey I need to mark max and min value of this graph with a red circle.
f = importdata("croc.txt");
deviation = f.data(:,1);
dates = f.textdata;
x = datenum(dates, "yyyy/mm");
y = deviation;
figure(1);
plot(x,y)
datetick('x','yyyy')
How can I then mark min and max peak with red circle?

채택된 답변

dpb
dpb 2019년 9월 23일
편집: dpb 2019년 9월 23일
[~,imx]=max(y);
[~,imn]=min(y);
hold on
plot(x([imn;imx]),y([imn;imx]),'or')
or as I was going to do originally as noted in comment:
ix=[imn;imx];
plot(x(ix),y(ix),'or')
  댓글 수: 7
PAVARNA TA
PAVARNA TA 2021년 5월 17일
how to mark only the minimum or the maximum point?
dpb
dpb 2021년 5월 17일
Just leave out the one not wanted...

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by