如何使用 Matlab 制作简单的 FIR 滤波器?
如何使用 Matlab 制作一个简单的低通 FIR 滤波器(不使用内置函数)?
问题示例:
Implement a FIR LPF with cut-off frequency 250Hz
可能还需要给出采样频率...
解决方案尝试或我已经知道的:
x = [...] -> input signal
A = 1; -> Since this is FIR
B = [?????]
y = filter(B, A, x) -> Output signal
Afaik,B 应该包含 FIR 滤波器的系数。但;鉴于我只有截止频率,如何计算这些系数?
How can I make a simple low-pass FIR filter using Matlab (without using the built-in function) ?
Problem example:
Implement a FIR LPF with cut-off frequency 250Hz
it may also be necessary that, sampling freq is given...
Solution attempt or what I already know:
x = [...] -> input signal
A = 1; -> Since this is FIR
B = [?????]
y = filter(B, A, x) -> Output signal
Afaik, B should contain the coefficients for the FIR filter. But; how do I calculate these coefficients given that I only have the cut-off frequency?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
最简单的是“加窗正弦”滤波器:
滤波器的长度(参见
t=...
)控制过渡带的宽度。在这种情况下,cutoff
是 -6 dB 点。blackman
是一个流行窗口的名称。您可以查看此维基百科页面以获取有关窗口函数的更多信息。它们基本上在过渡带宽和阻带抑制之间有不同的权衡。The simplest thing is a "windowed sinc" filter:
The length of the filter (see
t=...
) controls the width of the transition band.cutoff
is in this case the -6 dB point.blackman
is the name of a popular window. You can check out this Wikipedia page for more infos on window functions. They basically have different trade-offs between transition band width and stopband rejection.如果您不想要不同形状的幅度谱,请完全按照 sellibitze 的建议进行操作,仅将 sinc 函数替换为所需幅度响应的傅里叶逆变换的实部(延迟以获得因果对称脉冲响应)。
If you wan't a different shape of the amplitude spectrum, do exactly as sellibitze suggested, only replace the sinc function with the real part of the inverse Fourier-transform of the desired amplitude response (delayed to get causal symmetrical impulse response).
由于 LTI 滤波器的系数是时域脉冲响应,因此您可以通过指定振幅向量和相位向量在 matlab 中创建频率响应,然后对它们进行反向 FFT 以获得系数,例如,类似
A = [ 1 .9 .8 .5 .2 .1 0]
,theta=[0 0 0 0 0 0 0]
,然后H=A.*exp (j*theta)
然后coefs = ifft(H)
Since the Coefficients to a LTI filter are the time domain impulse response, you could create the frequency response in matlab by specifying an Amplitude vector, and and Phase Vector, then Inverse FFT them to get your coefficients, for example, soemthing like
A = [ 1 .9 .8 .5 .2 .1 0]
,theta=[0 0 0 0 0 0 0]
, thenH=A.*exp(j*theta)
thencoefs = ifft(H)