Finding local minimums/maximums for a set of data

181 ビュー (過去 30 日間)
Si14
Si14 2012 年 7 月 21 日
コメント済み: Umesh Gautam 2023 年 5 月 11 日
Hi, I have a set of data which oscillates between minimums and maximum values. The min and max values change slightly over time. I want to see the trend of changing of min and max values over time. In order to do that, it seems that I need to extract the local min and local maximums.
Is there any function to extract the local minimums and maximums of the following graph?
Thanks.
  4 件のコメント
Steev Mathew
Steev Mathew 2021 年 3 月 4 日
Thanks! This helped me a lot. I was looking for a way to filter out noise from my data.
Anupama V
Anupama V 2022 年 11 月 6 日
How to find the valley of a ppg signal?(secondary peak of a signal)

サインインしてコメントする。

採用された回答

Star Strider
Star Strider 2012 年 7 月 22 日
編集済み: Star Strider 2012 年 7 月 22 日
Another option is ‘findpeaks’ in the Signal Processing Toolbox. It will give you the maximum (and indirectly the minimum) values and their index locations. If ‘Data’ is the vector that produced the plot, to find the maxima and minima:
[Maxima,MaxIdx] = findpeaks(Data);
DataInv = 1.01*max(Data) - Data;
[Minima,MinIdx] = findpeaks(DataInv);
The true minima will then be:
Minima = Data(MinIdx);
The index values also allow you to determine the times the maxima and minima occurred.
  9 件のコメント
Christos-Nikolaos  Zacharopoulos
Christos-Nikolaos Zacharopoulos 2018 年 2 月 27 日
Hi, I know that this is an old question, but why is the signal inverted using : DataInv = 1.01*max(Data) - Data; Cheers,
Star Strider
Star Strider 2018 年 2 月 27 日
For some reason, it was important that the inverted waveform be greater than zero. (That was years ago, so I don’t remember the details.)
That’s likely not necessary for every signal. If you want the minima, just negate the original signal and use the indices findpeaks returns in the second output to get the values of the original signal.
I you have R2017b, the islocalmin function is also an option to get the minima without inverting the signal.

サインインしてコメントする。

その他の回答 (5 件)

Steven Lord
Steven Lord 2021 年 3 月 4 日
For more recent releases take a look at the islocalmin, islocalmax, and (perhaps) detrend functions.

Si14
Si14 2012 年 7 月 26 日
Thank you guys for your responses. I am using the following and it works nice:
[Maxima,MaxIdx] = findpeaks(Data);
DataInv = 1.01*max(Data) - Data;
[Minima,MinIdx] = findpeaks(DataInv);
Minima = Data(MinIdx);
  2 件のコメント
Star Strider
Star Strider 2012 年 7 月 26 日
Thank you for accepting my answer!
Umesh Gautam
Umesh Gautam 2023 年 5 月 11 日
It is working great.

サインインしてコメントする。


Image Analyst
Image Analyst 2012 年 7 月 22 日
編集済み: Image Analyst 2012 年 7 月 22 日
If you have the Image Processing Toolbox, you can use imregionmax() and imregionalmin(). Do you have that toolbox? If you do that would be the simplest because it's just simply one line of code to find either the maxs or the mins.
You can also do it by seeing where the morphological max or min (performed by imdilate() and imerode() respectively) equals the original array. But again, that requires the Image Processing Toolbox.

Randy82
Randy82 2014 年 8 月 13 日
I have one question: Why do i have to multiply max(Data) with a factor 1.01?
  1 件のコメント
Star Strider
Star Strider 2014 年 8 月 13 日
To keep all the values of the inverted vector > 0.

サインインしてコメントする。


Prithisha K
Prithisha K 2021 年 9 月 8 日
Set the prominence window value to 25. Then increase the min.prominence value untill there are exactly 9 minima found.

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by