필터 지우기
필터 지우기

Finding the best parameters for Savitzky-Golay filter

조회 수: 35 (최근 30일)
Vince Roman
Vince Roman 2015년 2월 17일
댓글: KAE 2019년 4월 9일
Hello,
I have been using Savitzky-Golay filter to smoothed a noisy signal.
There are 2 options for parameters, N: Polynomial fit and F: Window length
Are there any ways to quantify which best filter would be to use?
Below is for a polynomial fit of 2 and different window lengths for different filters
I know that by looking at the graph visually, you can at an extent say which filter is best but is there a possibility that a number can be generated in a form of comparison from each filters?
Regards

답변 (2개)

Jan
Jan 2015년 2월 17일
It depends on how you define "best". It is impossible to find a unique definition for "best" filter parameters, because this depends on the nature of the signal: A filter should distinguish between the noise and the wanted signal. But the noise could have lower or higher frequencies than the wanted signal, and both can have different frequency spectra in addition.
So how do you define "good" in your specific case?
  댓글 수: 3
Jan
Jan 2015년 2월 17일
Again: It is impossible to find a general method to obtain the "original" signal. It depends on the nature of the signal and of the noise. Imagine that you have a sine wave and triangle wave with two different frequencies. Then it matters for the "best" filter parameters, if you want to obtain the sine or the triangle wave.
You can use the Mean Absolute Deviation, if this satisfies your needs. Do you have the original signal for a comparison?
Vince Roman
Vince Roman 2015년 2월 17일
Yes,
This is my current codes that I used for this sine wave:
xLim = 1000; % Generate numbers from 0 to 1000.
dx = 0.01; % Increment of 0.01.
x = 0:dx:xLim-1; % Generate a series of numbers from 0 to 999 (xLim-1) with increment of 0.01.
y0 = 6*sin(0.4*pi*x); % Create sine signal.
y = awgn(y0,10,'measured'); % Add white Gaussian noise lowest to highest 10, 6, 3, 0.01
This is saved as SineNoise1. I then apply the filters with different polynomial fit/window lengths.
This new figure might make more sense:
I am trying to find a way to use to compare the different filters with one another on different noise level signals and also on different waveforms such as triangle, square and complex.
Using the Mean Absolute Deviation, it has worked for the sine, triangle and complex wave but they are all giving me the same filter as the 'best' one which made me think if that is actually the case.
However, for the square wave the mad(x) doesn't give similar results, could it be due to the codes I use? y = square(2*x)

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


swapnil mishra
swapnil mishra 2018년 1월 9일

HOW TO KNOW THE ORDER AND FRAMELENGTH ??

clc

clear all

close all

[x,fs]=audioread('Record_0001.wav'); %load the sound

sound(x,fs)

pause(3)

figure(1)

plot(x)

x = x+(randn(size(x)));

figure(2)

plot(x)

sound (x,fs);

pause(3)

order = 8;

framelen = 21;

b = sgolay(order,framelen);

y = conv(x,b((framelen+1)/2,:),'valid');

z = b(end:-1:(framelen+3)/2,:) * x(framelen:-1:1);

z1 = b((framelen-1)/2:-1:1,:) * x(end:-1:end-(framelen-1));

sound(x)

z3 = sgolayfilt(x,7,41);

y = [z; y; z1];

figure(3)

plot([x y])

legend('Noisy Sinusoid','S-G smoothed sinusoid')

figure(4)

sound(z3,fs)

subplot(2,1,1) plot(1:2000, x(1:2000)) axis([0 2000 -4 4]) title('mtlb') grid

subplot(2,1,2) plot(1:2000,z3(1:2000)) axis([0 2000 -4 4])

title('smtlb') grid

                                 graph_of_input_speech
                                 graph_of_input_speech_with_noise
                                 graph after using sgolay
                                couldn't get desired output
  댓글 수: 1
KAE
KAE 2019년 4월 9일
Can you put some description in your answer to tell what you are doing? I can't see how you are estimating the optimal frame length and polynomial order here.

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

카테고리

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