adaptive savitzky golay to find optimum order and window size

2 visualizzazioni (ultimi 30 giorni)
Hi
I need to apply adaptive SG filter to my data to find the optimum order and window size. I used below code
to generate smoothed signal from the noise one , I need to find SG order and window size that preserve the
peaks in the signal and reduce the signal fluctuation between them .
for order =(0:1:9) ;
for framelen =(1:2:51);
x=-AV;
lx = 20;
sgf = sgolayfilt(x,order,framelen);
plot(sgf);
hold on;
end
end

Risposte (1)

Image Analyst
Image Analyst il 10 Mag 2017
Find the peaks first with findpeaks(). Then replace those locations with the original signal in small windows around the peaks. So make a logical vector that's true where you want original spikes and false where you want the SG filtered signal, then do
sgf(peaksMask) = x(peaksMask);
  4 Commenti
sarmad m
sarmad m il 11 Mag 2017
@ Jan Simon
I need to find the order and window size of SG filter that can preserve the peaks and reduce noise . Currently i'm changing the ( order and framelen ) of SG for each new data file . as you see in the image above I tried different order and window size but I don't know how to find out the best parameters
Jan
Jan il 11 Mag 2017
@sarmand m: All orders and window sizes do reduce the noise and preserve the peaks in a certain degree. You are looking for the "optimal" order and window size, but you did not specify how this is measured. How do you decide which filter parameters are "better"? There is no magic set of parameters which leave the peaks untouched and removes all noise. You cannot even know if the exact peak height is caused by noise.
Do you see the problem? To find the "best" parameters, you have to start with defining what "good" is mathematically.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by