Mark max value and min value with red circle

22 Ansichten (letzte 30 Tage)
Mathias Pettersen
Mathias Pettersen am 23 Sep. 2019
Kommentiert: dpb am 17 Mai 2021
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?

Akzeptierte Antwort

dpb
dpb am 23 Sep. 2019
Bearbeitet: dpb am 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 Kommentare
PAVARNA TA
PAVARNA TA am 17 Mai 2021
how to mark only the minimum or the maximum point?
dpb
dpb am 17 Mai 2021
Just leave out the one not wanted...

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by