How do I filter correctly ?

Hi,
I have two small signals sampled both on 15360Hz:
1)"almost" a SIN, with fundamental frequency on 60Hz. 2) a noise signal (that would represent a SIN too), with fundamental frequency on 60Hz too.
I want to smooth the second signal, so, I did a 2. order butterworth LP filter, cutting over 200Hz.
So, plotting the 2 signal, I got the noised signal smoothed like I want.
The problem is,
If I took the same filter (LP) on the 1 signal, it will change its magnitude. Why (the first signal just have signals down the 200Hz) ??? Am I missing some theory ??
My butterworth:
function Hd=filtsignal
Fs=15360;
N=2; % order
Fc = 200; % cutoff
h=fdesign.lowpass('N,F3db', N, Fc, Fs);
Hd=design(h,'butter');
On my main code:
% y is the 1 signal
y=filter(filtsignal,y);
% y2 is the 2 signal
y2=filter(filtsignal,y2);
Andre

 采纳的回答

Star Strider
Star Strider 2014-5-22

0 个投票

I don’t completely understand. However if you filter out noise, the magnitude of the output signal from the filter will decrease because you’ve removed some of the energy in the signal.
Also, I suggest using filtfilt rather than filter. It eliminates phase distortion.

4 个评论

Hi Strider,
let me try explain in a different way:
I have a signal that I want to cutoff over 200Hz. I designed a filter with this properties.
If I use the same filter, in another signal, like a SIN with the fundamental on 100Hz. Why I gotta differences at the magnitude, if the filter is cutting over 200Hz ?
Thanks,
Andre
When I simulate your situation with a pure sine, then filter it, it’s apparent that the filter is reducing the energy of the filtered signal. There are ‘harmonics’ inherent in any digitised signal, and the filter is eliminating some of these, and that affects the amplitude of the filtered signal. There is also some filter attenuation in the passband at 100 Hz, even though the cutoff is 200 Hz.
Yes,
that´s what I thought.
There is a way (another matlab filter alg) that can do this without so much attenuation ?
Andre
You might be able to reduce the attenuation by using a higher-order filter, and using tf2sos and then filtfilt (with the second-order-section syntax) instead of filter. The filtfilt function will eliminate phase distortion. Other filter designs (Chebyshev, elliptic) have different passband characteristics that might work better in your application. The only way to find out which is best is to experiment.

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by