Mark max value and min value with red circle

24 ビュー (過去 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 Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by