Finding peak of a noisy data

조회 수: 33 (최근 30일)
mpz
mpz 2022년 8월 15일
답변: William Rose 2022년 8월 15일
I need help with finding peaks (in other words cycles) for the plot below.(data attached). I tried two methods but still cannot get it right. Using the finepeaks it kept giving me peaks that at not really peaks. With polyfit, the curve wasn't fitting "accurately". Any help is appreciated.
findpeaks(ans(:,2),'MinPeakDistance',7000);
findpeaks(ans(:,2),'MinPeakHeight',200);
findpeaks(ans(:,2),'Threshold',5);
findpeaks(ans(:,2),'MinPeakWidth',100);
findpeaks(ans(:,2),'WidthReference','halfprom','MinPeakHeight',200,'Threshold',4,'MinPeakDistance',100);
OR
x=ans(:,1);
y=ans(:,2);
p = polyfit(x,y,6);
y1 = polyval(p,x);
figure(2005)
plot(x,y1,x,y)

답변 (2개)

William Rose
William Rose 2022년 8월 15일
I see that you have experimented with some of the many options in findpeaks(). You may need to combine the options to reliably identify the "real" peaks, i.e. those that you regard as peaks.
When I look at this plot, I am not sure which local maxima are the real peaks, and which are not, and why. I reocmmend that you add symbols at the "real" peaks, and think about why you have rejected the other local maxima. This process may help you determine the correct combination of options for findpeaks().

William Rose
William Rose 2022년 8월 15일
data=load('noisy.mat');
t=data.ans(:,1); x=data.ans(:,2); %extract the data
plot(t,x,'-b'); grid on; hold on %plot the data
%next: find some peaks
[pks,locs]=findpeaks(x,t,'MinPeakDistance',7000/8,'MinPeakHeight',200,...
'Threshold',5,'MinPeakWidth',100/8);
plot(locs,pks,'*r'); %add found peaks to the plot
In the script above, I divided the parameters that have units of distance (or time) (minpeakdistance, minpeakwidth) by 8, because I have passed t, the vector of locations. The sampling interval for t is approximately 1/8. Therefore the location-dependent parameters must be scaled accordingly. I passed vector t so that the locs vector which is returned by findpeaks() will correspond to the horizontal coordinates of the original data. This allows me to plot the found peaks in the right places.
Experiment with the above.

카테고리

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