adaptive savitzky golay to find optimum order and window size

조회 수: 2 (최근 30일)
sarmad m
sarmad m 2017년 5월 10일
댓글: Jan 2017년 5월 11일
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

답변 (1개)

Image Analyst
Image Analyst 2017년 5월 10일
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
sarmad m
sarmad m 2017년 5월 11일
@ 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 2017년 5월 11일
@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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Smoothing and Denoising에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by