フィルターのクリア

How can I find a minimum only before a peak has been detected?

9 ビュー (過去 30 日間)
Ana Silva
Ana Silva 2018 年 5 月 23 日
コメント済み: Folakemi Omotoye 2018 年 7 月 24 日
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 件のコメント
jonas
jonas 2018 年 5 月 23 日
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
Folakemi Omotoye 2018 年 7 月 24 日
Hi Anna, How did you get this kinda plot. I want to get a similar plot to this

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

採用された回答

jonas
jonas 2018 年 5 月 23 日
編集済み: jonas 2018 年 5 月 23 日
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 件のコメント
jonas
jonas 2018 年 5 月 23 日
Great!
Image Analyst
Image Analyst 2018 年 5 月 24 日
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.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by