Finding local minimums/maximums for a set of data

Asked by Si14 on 21 Jul 2012
Latest activity Commented on by Star Strider on 26 Jul 2012

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.

0 Comments

Si14

Products

No products are associated with this question.

3 Answers

Answer by Star Strider on 22 Jul 2012
Edited by Star Strider on 22 Jul 2012
Accepted answer

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.

0 Comments

Star Strider
Answer by Image Analyst on 22 Jul 2012
Edited by Image Analyst on 22 Jul 2012

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.

0 Comments

Image Analyst
Answer by Si14 on 26 Jul 2012

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);

1 Comment

Star Strider on 26 Jul 2012

Thank you for accepting my answer!

Si14

Contact us