Notch filtering from coefficients

14 次查看(过去 30 天)
Hi, I'm working on a notch filter to remove a peak in my spectrum. I designed the filter in different ways (fdesign.notch principally) and I get 6 coefficients. I tried filtering just with notchfilt(signal) but by plot seems nothing happens. Is this correct?
BTW how can I filter by using these coefficients? filtfilt accepts only 2..
Thanks
F0 = 2690; % interference is at
Fs = 44100; % sampling frequency is
notchspec = fdesign.notch('N,F0,Q',2,F0,100,Fs);
notchfilt = design(notchspec,'SystemObject',true);
% fvtool(notchfilt,'Color','white');
FOA_mag = notchfilt(Xa_mag); % xa_mag is the magnitude from fft of the signal
% got these coefficients from struct:
notchfilt.SOSMatrix
ans =
1.0000 -1.8549 1.0000 1.0000 -1.8514 0.9962

采纳的回答

Star Strider
Star Strider 2020-7-5
编辑:Star Strider 2020-7-6
The function gives you the ‘b’ vector for the filter. The ‘a’ vector is 1, since this appears to be a FIR filter design.
To understand how the filter works, use freqz:
figure
freqz([1.0000 -1.8549 1.0000 1.0000 -1.8514 0.9962], 1, 2^16, 44100)
Use the first two arguments with filtfilt.
(I do not have the DSP System Toolbox, so I cannot comment further on your code.)
EDIT — (5 Jul 2020 at 00:18)
I would design the filter this way:
F0 = 2690;
Fs = 44100;
Fn = Fs/2;
fcuts = [2600 [-5 5]+F0 2790];
mags = [10 0 10];
devs = [0.1 0.05 0.1];
[n,Wn,beta,ftype] = kaiserord(fcuts,mags,devs,Fs);
b = fir1(n, Wn, 'stop', kaiser(n+1, beta), 'noscale');
figure
freqz(b, 1, 2^16, Fs)
.
  2 个评论
Giorgio Frignani
Giorgio Frignani 2020-7-6
Fantastic, it seems to work in both ways! I just didn't get coefficients meaning..
Thank you

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Filter Design 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by