The fastest way to find local minimum

4 vues (au cours des 30 derniers jours)
Hg
Hg le 20 Oct 2015
Commenté : Hg le 20 Oct 2015
What is the most efficient/fastest way to find the circled local minimum below, the lowest minima between two highest peaks? The graph was created by plot(x,y).
  5 commentaires
Walter Roberson
Walter Roberson le 20 Oct 2015
Never name a variable "min"; that interferes with using the MATLAB min() function. For example,
[peaks, locs] = findpeaks(x, y,'MinPeakProminence',100);
[minval, minidx] = min( x(locs(1):locs(2)) );
%minidx is relative to the subset of values, so move it back to full range
minidx = minidx + locs(1) - 1;
Hg
Hg le 20 Oct 2015
Modifié(e) : Hg le 20 Oct 2015
Thanks for the advice. I think using 'MinPeakProminence' to get 2 highest peaks is not robust enough. It might get more than 2 peaks like below where the first and second peak have same value.

Connectez-vous pour commenter.

Réponse acceptée

Image Analyst
Image Analyst le 20 Oct 2015
Invert your signal
invertedSignal = max(signal(:)) - signal;
Now valleys will be peaks. Then call find peaks.
  1 commentaire
Hg
Hg le 20 Oct 2015
ok, this is genius!

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by