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
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
2015-12-11
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
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).
类别
在 帮助中心 和 File Exchange 中查找有关 Descriptive Statistics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!