如何使用 Matlab 制作简单的 FIR 滤波器?

发布于 2024-08-11 09:14:07 字数 374 浏览 6 评论 0原文

如何使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

巴黎夜雨 2024-08-18 09:14:07

最简单的是“加窗正弦”滤波器:

fs = 44100;
cutoff = 250;
t = -256:256;  % This will be a 513-tap filter
r = 2*cutoff/fs;
B = sinc(r*t).*r .* blackman(length(t))';
freqz(B);

滤波器的长度(参见t=...)控制过渡带的宽度。在这种情况下,cutoff 是 -6 dB 点。 blackman 是一个流行窗口的名称。您可以查看维基百科页面以获取有关窗口函数的更多信息。它们基本上在过渡带宽和阻带抑制之间有不同的权衡。

The simplest thing is a "windowed sinc" filter:

fs = 44100;
cutoff = 250;
t = -256:256;  % This will be a 513-tap filter
r = 2*cutoff/fs;
B = sinc(r*t).*r .* blackman(length(t))';
freqz(B);

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.

音栖息无 2024-08-18 09:14:07

如果您不想要不同形状的幅度谱,请完全按照 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).

走过海棠暮 2024-08-18 09:14:07

由于 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], then H=A.*exp(j*theta) then coefs = ifft(H)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文