Mark max value and min value with red circle

21 views (last 30 days)
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?

Accepted Answer

dpb
dpb on 23 Sep 2019
Edited: dpb on 23 Sep 2019
[~,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 Comments
PAVARNA TA
PAVARNA TA on 17 May 2021
how to mark only the minimum or the maximum point?
dpb
dpb on 17 May 2021
Just leave out the one not wanted...

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!