MinPeakProminence error in findpeaks - detecting unwanted signal

7 views (last 30 days)
I am trying to use the findpeaks function to look for sharp and intense peak in 100 spectra. Here is an example of my spectrum:
I tried different name-value arguments so that it would look for sharp and intense peaks only. However, it seems like the 'MinPeakProminence' is not working as expected.
When I apply the following line to the spectrum above (I limited the number of peaks (NPeaks) to 1 for simplier visualization) :
load ('Data.mat'); figure;
findpeaks(y, 'MinPeakProminence',0.15,'NPeaks',1,'MaxPeakWidth',20,'MinPeakDistance',7,'Annotate','extents');
This is what it gives me:
It seems like the function is drawing its own borders and using the boaders as lowest left and right intervals (This is just my observation, not sure if I intepreted that correctly).
Below shows the magnified detected "peak":
Has anyone encounter the same issue? Any help would be greatly appreciated.
Thanks in advance!
  5 Comments
Mathieu NOE
Mathieu NOE on 10 May 2023
in other words , maybe there is better alternative (if I get what you're looking for)
See Yoong Wong
See Yoong Wong on 11 May 2023
Edited: See Yoong Wong on 11 May 2023
@Mathieu NOE I see! I am looking for peaks like this one:
Peaks like this one might appear anywhere along the x-axis. They can have varied intensity (prominence between 0.1 to 0.95), but they should be sharp (width between 3 to 15 datapoints).

Sign in to comment.

Accepted Answer

Mathieu NOE
Mathieu NOE on 11 May 2023
hello again
this would be my suggestion
hope it helps
load ('Data.mat');
[PKS,LOCS,W,P] = findpeaks(y, 'MinPeakProminence',0.15,'MaxPeakWidth',15,'MinPeakDistance',100);
% rejet peaks above 0.9 (the ones that could be on the y = 1 plateau)
id = (PKS<0.9);
PKS = PKS(id);
LOCS = LOCS(id);
W = W(id);
P = P(id);
% then select the first one (along the x axis)
PKS = PKS(1);
LOCS = LOCS(1);
W = W(1);
P = P(1);
figure;
plot(y); hold on
plot(LOCS,PKS,'dr');

More Answers (0)

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!