Neamah Al-Naffakh
Neamah Al-Naffakh

Reputation: 163

Finding local minima for a signal

I have used the findpeaks function in MATLAB to find the locations and the values of the peaks (Local Maxima) in the signal.

[pks, locs] = findpeaks(X_Segments{nn},'MinPeakDistance', 20);
AverageDistance_Peaks(nn,:) = mean(diff(locs));

X_Segments contains the data.

Is there any function to extract the local minimums of the following graph?

Graph shows the Local Maxima Graph shows the Local Maxima

Upvotes: 2

Views: 751

Answers (1)

Suever
Suever

Reputation: 65430

Just negate your signal first. This will then give you the local minima.

% Pass a negative version of X_segments
[pks, locs] = findpeaks(-X_Segments{nn},'MinPeakDistance', 20);
AverageDistance_Peaks(nn,:) = mean(diff(locs));

% Change the sign back to be the correct one
pks = -pks;

Upvotes: 1

Related Questions