How can i find this minima?

Hi everyone!
I have a question regarding finding peaks. I already used the "peakfinder"- function by Nathanael Yoder to find the 5 peaks (maximum), but I also have to find the marked values (minima). By doing it with his function I do not get them properly
. Does someone have an idea how to solve it? Many thanks in advance!

 Accepted Answer

Star Strider
Star Strider on 7 Oct 2017
One approach is to use diff or gradient to calculate the approximate derivative of your data. Then ‘threshold’ the negative values of the derivative to be as large as necessary to detect the abrupt negative changes. Those will give you the points where the change is greatest. Calculating the points with the red arrows should be relatively straightforward.
The easiest way to find those using findpeaks is probably to first negate your signal (so the ‘dips’ become peaks), then use findpeaks to find the ‘peaks’ of the negated signal. Subtract as many indices as you need from those returned by findpeaks to get the points indicated by the arrows.

More Answers (1)

While it is not a very robust method, these points are the last points of the curve before the derivative becomes very negative. You could get them simply with:
pos = find( diff( signal ) < -4 ) ;
or use [diff(signal)<-4], false] for performing logical indexing, and you may want to subtract some offset to the positions if you want to get points a little before the signal starts going down.

4 Comments

Thanks alot. I implemented the code as you described above, but i also want to add an 'and'-condition, so that it checks, if the gradient one step to the left (in reference to the found location of your the code) fullfills a specific condition.
Cedric
Cedric on 8 Oct 2017
Edited: Cedric on 8 Oct 2017
Try something along this line:
d = diff( signal ) ;
pos = find( d < -4 ) ;
isRelevant = d(pos-1) < 0 ; % Or any other condition(s).
pos = pos(isRelevant) ;
What function is 'posStep'? or could you explain what:
pos = posStep(isRelevant) ;
does? Thanks in advance!
My mistake, I updated variable names to simplify the notation and I forgot to change this one! See the updated comment.

Sign in to comment.

Asked:

on 7 Oct 2017

Commented:

on 8 Oct 2017

Community Treasure Hunt

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

Start Hunting!