如何使用Matlab做一个简单的FIR滤波器? [英] How to make a Simple FIR Filter using Matlab?
问题描述
问题示例:
执行截止频率为250Hz的FIR LPF
可能还需要取样频率给定...
解决方案尝试或者我已经知道的:
x = [...] - >输入信号
A = 1; - >由于这是FIR
B = [
y] = filter(B,A,x) - >输出信号
Afaik,B应包含FIR滤波器的系数。但;我怎么计算这些系数给定我只有截止频率?最简单的事情是一个窗口sinc filter:
fs = 44100;
cutoff = 250;
t = -256:256; %这将是一个513抽头滤波器
r = 2 * cutoff / fs;
B = sinc(r * t)* r。* blackman(length(t))';
freqz(B);
过滤器的长度(参见 t = ...
)控制过渡带的宽度。在这种情况下, cutoff
是-6 dB点。 blackman
是一个受欢迎的窗口的名称。您可以查看这个维基百科页面以获取更多关于窗口功能的信息。它们在转换带宽和阻带抑制之间基本上有不同的权衡。
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?
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.
这篇关于如何使用Matlab做一个简单的FIR滤波器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!