Removing peaks less than threshold
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Trevor Evans
el 11 de Abr. de 2024
Comentada: Voss
el 13 de Abr. de 2024
Hi,
I have a time series which has fairly large cyclical peaks (~1sec) that I used the findpeaks function to identify. However, there are sometimes lesser spurious peaks which I am trying to eliminate. I've tried to set a threshold for minimum peak distance of 0.7sec using the diff function to get rid of the smaller peaks, but this has sometimes resulted in also removing the larger peaks that I would like to keep. I know I need to use the y-values from the peaks to keep the larger values but am unsure how to incorporate that into the algorithm. For example, given this data of peaks:
[LMaxValues2,LMaxInd2] = findpeaks(data.Y,'MinPeakProminence',0.1,'Annotate','extents'); %find data peaks
LMaxTimes2 = data.time(LMaxInd2); %turn peak indices into timestamps
badpts = diff(LMaxTimes2)<0.7; %threshold 0.7s to eliminate minor spurious peaks
LMaxTimes2(badpts)=[]; %Eliminate times of fake peaks from array
LMaxValues2(badpts)=[]; %Eliminate values of fake peaks from array
LMaxTimes2 = [292.498 293.517 294.543 295.117 295.556 296.548];
LMaxValues2 = [0.0097 -0.027 0.0412 -0.4127 0.0111 -0.011];
I want it to keep points 1,2,3,4,6, outputting:
LMaxTimes2 = [292.498 293.517 294.543 295.556 296.548]
LMaxValues2 = [0.0097 -0.027 0.0412 0.0111 -0.011];
But I'm getting:
LMaxTimes2 = [292.498 293.517 294.543 296.548]
Since the diff(LMaxTimes2) for points 3-4 and 4-5 both cross the <0.7 threshold.

Hope this was clear, thank you!
2 comentarios
Image Analyst
el 11 de Abr. de 2024
Do you just want to find the shorter peaks on the left shoulder of the big peak and delete everything in the x and y arrays between the valleys on each side of the shoulder peak? Or did you want to change the values, like interpolate a smooth function between the valleys?
Respuesta aceptada
Voss
el 11 de Abr. de 2024
Try using MinPeakHeight and/or MinPeakDistance in findpeaks, instead of MinPeakProminence. You'll likely be able to entirely avoid removing elements afterward based on diff.
2 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!