lowest peak between two values

Hello
I need to find the lowest minimum peak between every maximum peak. As you can see in the image
every red peak has more than one green peak in between. I want the lowest one. (by the way I also need the lowest at the beginning and at the end). I should get 11 green peaks, no more.
How can I do? I make a total mix-mess in my head between the functions find, min, max and findpeaks.
function [pp,pn,lp,ln,keep] = AllPeaks(ang)
[pp,lp] = findpeaks(ang,'minpeakheight',1.1,'MinPeakDistance',150);
[pn,ln] = findpeaks(-ang,'minpeakheight',0.5,'MinPeakDistance',50); % réfléchir au 150. peut-on le réduire. regarde les différents plots
pn = -pn;
w2 =[];
[taille, w] = size(lp);
for i=1:1:taille-1
w2 = [w2; ln(ln>lp(i) & ln<lp(i+1))];
index_i = [];
[taille2, w3] = size(w2);
for i=1:1:taille2
index_i = [index_i; find(w2(i))];
end
keep = [];
[taille3, w4] = size(index_i);
for i=1:1:taille3-1
if (pn(i) < pn(i+1))
keep = [keep; pn(i)];
end
if (pn(i) > pn(i+1))
keep = [keep; pn(i+1)];
end
end
end
This code is repeating the values I want twice sometimes. So there is something I am double doing.
Thank you very much

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 12 月 11 日

0 投票

If you have a routine that can reliably find maximum peaks, then you can find the lowest minimum by asking the routine to find the maximum of negative one times the signal.

3 件のコメント

Tshahé Anongba
Tshahé Anongba 2015 年 12 月 11 日
Hello I don't have a routine that can reliably find maximum peaks. I just ask what are the positif peaks. I just happen to be lucky the positive peaks are easier to find than the negative ones.
Image Analyst
Image Analyst 2015 年 12 月 12 日
You're already doing it:
[pn,ln] = findpeaks(-ang,..............
Taking the negative basically inverts the signal so that your major valleys are now major peaks. You just need adjust the parameters to find big peaks, not little ones. It may help you if you plotted -ang to see what it looks like.
Adi Purwandana
Adi Purwandana 2023 年 4 月 16 日
Hello, I follow your suggestion...and it's fine. Anyway I'm doing this:
%peaks
[pks1,locs1] = findpeaks(A,D,'MinPeakProminence',4,'Annotate','extents');
findpeaks(A,D,'MinPeakProminence',4,'Annotate','extents'););
%lowest
[pks2,locs2] = findpeaks(-A,D,'MinPeakProminence',4,'Annotate','extents'););
findpeaks(-A,D,'MinPeakProminence',4,'Annotate','extents');
My question then is: how to put the lowest symbols attached to the first plot (pks1)? Because I need only a plot with the peak and lowest values in a plot (pks1 plot).

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

質問済み:

2015 年 12 月 10 日

コメント済み:

2023 年 4 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by