Filtering of 60Hz noise signal - output not expected

20 views (last 30 days)
I'm trying to figure out why this stopband filter to remove 60Hz noise makes things worst.
d=designfilt('bandstopiir','FilterOrder',20','HalfPowerFrequency1',58,'HalfPowerFrequency2',62,'SampleRate',31500);
fvtool(d)
As you can see the response looks like what I would expect. However, upon applying it to my signal, the 60Hz harmonic looks worst:
out = filter(d,SAMPLE);
figure;plot(tt,SAMPLE,'r',tt,out,'b');xlabel('Time (sec)');ylabel('Amplitude (counts');
legend({'SAMPLE','out (filtered)'});
Even the power density plots imply that the 60Hz signal and surrounding frequencies were actually amplified:
[pSAMPLE,fSAMPLE]=periodogram(SAMPLE,[],length(SAMPLE),31500);
[pOut,fOut]=periodogram(out, [], length(out), 31500);
figure;plot(fSAMPLE,20*log10(abs(pSAMPLE)),'r',fOut,20*log10(abs(pOut)),'b');xlabel('Frequency (Hz)');ylabel('dB')
Now admittedly, I'm very new to DSP processing. But, can anyone point out what I'm doing wrong? Shouldn't the periodogram of the filtered signal essentially be SAMPLE's periodogram multipled by the filter (fvtool) response? Thanks for any help! -Scott

Accepted Answer

Star Strider
Star Strider on 6 Feb 2016
Your filter order may be too high. I would use the 60 Hz notch filter example in the documentation: Remove the 60 Hz Hum from a Signal.
  4 Comments
Scott Norton
Scott Norton on 6 Feb 2016
Thanks!! It seems using filtfilt() rather than filter() was the key. I didn't notice that the Matlab 60Hz hum example did indeed using filtfilt() rather than filter() until I looked at it again following your comment. Admittedly, now I need to really understand why the "zero-phase" digital filtering rather than the "generic" filter() function makes such a difference. I'm used to focusing on the magnitude of the filter response (and signal PSD) when intuitively trying to assess the response, but I guess I need to better understand how that phase filter response impacts the overall signal filtering. Thanks again!
Star Strider
Star Strider on 6 Feb 2016
My pleasure!
I learnt about filtfilt a while ago when I tried to design a Gaussian filter (phase-neutral analog design) only to learn that it was not phase-neutral as a discrete filter, and that filtfilt made all discrete filters phase-neutral. In my (admittedly not humble) opinion, filtfilt is a huge bonus in getting the Signal Processing Toolbox, and worth getting it for filtfilt alone!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!