How can I find a minimum only before a peak has been detected?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ana Silva
am 23 Mai 2018
Kommentiert: Folakemi Omotoye
am 24 Jul. 2018
I have the following graph in which I used function findpeaks and MinPeakHeight to find the peaks that I'm interested in.
[pks,locs]=findpeaks(filter_sgo,'MinPeakHeight',limiar,'MinPeakDistance',minpkdist);
Now I want to find the local minimums but only before the peaks that I have already detected (red points of the picture). I know I have to invert the signal and use findpeaks again, but I can't figure out how to only detect before a peak.
Thanks a lot.
7 Kommentare
jonas
am 23 Mai 2018
If you post the data (or part of the data) and your code, then it would be easier to help you. It would also be easier to post a good answer. Anyway, I'm guessing this line is incorrect
if loc_min(1,:)< locs(1,j) && loc_min(1,:)>locs(1,j)-2000
you are never using i in your loop, perhaps : should be replaced by i?
Folakemi Omotoye
am 24 Jul. 2018
Hi Anna, How did you get this kinda plot. I want to get a similar plot to this
Akzeptierte Antwort
jonas
am 23 Mai 2018
Bearbeitet: jonas
am 23 Mai 2018
What you are looking for seems to be the beginning of the peak, which is not necessarily a valley. A simple method to approximate those values would be to count backwards from each peak, and find the location when the signal intercepts a predefined threshold. Here's a simple example. You may recognize the peaks from the documentation on findpeaks.
x = linspace(0,1,1000);
Pos = [1 2 3 5 7 8]/10;
Hgt = [3 4 4 2 2 3];
Wdt = [2 6 3 3 4 6]/100;
for n = 1:length(Pos)
Gauss(n,:) = Hgt(n)*exp(-((x - Pos(n))/Wdt(n)).^2);
end
PeakSig = sum(Gauss);
%%example starts here
[pks,locs] = findpeaks(PeakSig);
locs=[1 locs];
thres=0.5; %set threshold
win=diff(locs)
mins=nan(size(win))
for i=1:numel(win);
ind=find(PeakSig(locs(i):locs(i+1))<thres);
if ~isempty(ind)
mins(i)=max(ind)+locs(i);
end
end
mins(isnan(mins))=[];
figure;hold on
findpeaks(PeakSig)
plot(mins,PeakSig(mins),'rx')
3 Kommentare
Image Analyst
am 24 Mai 2018
Or (what I think might be better) is to descend from the peak until you're less than the threshold, and keep going until the values start to turn around and increase again.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!