【发布时间】:2014-04-26 17:37:50
【问题描述】:
我想借助 Matlab 中的线性相位 FIR 陷波滤波器和 IIR 陷波滤波器来隔离基频。谁能告诉我该怎么做?我知道我必须将陷波频率设置为基频。但是不明白怎么在MATLAB上实现。
【问题讨论】:
标签: digital-filter
我想借助 Matlab 中的线性相位 FIR 陷波滤波器和 IIR 陷波滤波器来隔离基频。谁能告诉我该怎么做?我知道我必须将陷波频率设置为基频。但是不明白怎么在MATLAB上实现。
【问题讨论】:
标签: digital-filter
你需要知道的事情。 采样率。 您希望隔离的基频。 FIR 滤波器基本和你想要什么顺序。 我建议制作一个带阻滤波器,它的阻带很薄。 阻带频率 fc1 和 fc2。 然后使用下面的代码。
fc1 = fundamental_freqeuncy1/sampling_rate;
fc2 = fundamental_freqeuncy2/sampling_rate;
N = 10; % number of taps you can change
n = -(N/2):(N/2); % 11 order filter
n = n+(n==0)*eps;
[h] = sin(n*2*pi*fc1)./(n*pi) - sin(n*2*pi*fc2)./(n*pi);
h(0) = 1 - (2*pi*(fc2-fc1))/pi;
%coefficient for band stop filter... which could be used % as notch filter
[w] = 0.54 + 0.46*cos(2*pi*n/N); % window for betterment
d = h.*w; % better coefficients
现在 d 是滤波器系数。 你的过滤器是
freqz(d); % use this command to see frequency response
在此之后,您需要使用系数“d”设计的过滤器过滤您的输入。 所以
y = filter(d,1,X) % X is input, y is filtered output
【讨论】:
这是您想要使用的一个 IIR 缺口代码。
fs = 20000; %#sampling rate
f0 = 50; %#notch frequency
fn = fs/2; %#Nyquist frequency
freqRatio = f0/fn; %#ratio of notch freq. to Nyquist freq.
notchWidth = 0.1; %#width of the notch
#%Compute zeros
zeros = [exp( sqrt(-1)*pi*freqRatio ), exp( -sqrt(-1)*pi*freqRatio )];
%Compute poles
poles = (1-notchWidth) * zeros;
figure;
zplane(zeros.', poles.');
b = poly( zeros ); %# Get moving average filter coefficients
a = poly( poles ); %# Get autoregressive filter coefficients
figure;
freqz(b,a,32000,fs) % 32000 are the sample numbers
%filter signal x
y = filter(b,a,x);
【讨论】: