필터 지우기
필터 지우기

Remove peaks below a threshold using findpeaks function

조회 수: 8 (최근 30일)
Konstantinos Tsitsilonis
Konstantinos Tsitsilonis 2017년 9월 8일
답변: Star Strider 2017년 9월 8일
Hi all,
I know this topic has been discussed before to some extent, but I can't seem to figure out a way to do the following.
I am finding peaks in my kernel distribution function which is returned in terms of PDF and X, where PDF vs. X is plotted. To find the peaks I do the following:
[Peaks, Locs] = findpeaks(PDF) ; %Find Y value of the peaks
X_peakVal = X(Locs) ; %Find X value of the peaks
However, I would like to reject some values for some peaks that lie below a threshold:
[Peaks, Locs] = findpeaks(PDF) ; %Find Y value of the peaks
Peaks(Peaks < 0.01*max(Peaks)) = [] ; %Reject Y value of peaks below this threshold
X_peakVal = X(Locs) ; %Find X value of the peaks
The above code does not reject the corresponding indices noted as Locs, such as the corresponding X_peakVal (or X values corresponding to the Y peaks) are also rejected.
What is a way to exclude the corresponding X values to the rejected Y?
Thanks in advance for your help,
KMT.

채택된 답변

Image Analyst
Image Analyst 2017년 9월 8일
You also need to remove those points from loc
smallPeakIndexes = Peaks < 0.01*max(Peaks);
Peaks(smallPeakIndexes) = [] ; %Reject Y value of peaks below this threshold
Locs(smallPeakIndexes) = [] ; %Reject Y value of peaks below this threshold

추가 답변 (1개)

Star Strider
Star Strider 2017년 9월 8일
This tweak to your code should work:
X_peakVal = X(Peaks < 0.01*max(Peaks)) ; %Find X value of the peaks
If that worked for ‘Peaks’ it should work for ‘X’ as well, since it creates the same logical index vector.

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by