在滤波器设计中使用 Matlab 的 sinc()?
Using Matlab's sinc() in filter design?
为了设计滤波器(windowing 方法),我首先生成我的 sinc 函数,如下所示:
L = 20;
fc = 0.25;
n = (1:L)';
my_sinc = sin(2*pi*fc*(n-L/2)) ./ (pi*(n-L/2));
my_sinc(L/2) = 2*fc;
然后我申请window:
win = blackman(L, 'symmetric');
filter_coeffs = (my_sinc .* win);
第一步可以用Matlab内置的sinc()
函数完成吗?
当然可以。您可以使用内置的 sinc
函数来获得与您在 my_sinc
中计算的结果完全相同的结果。由于 sinc(x) = sin(pi*x)/(pi*x)
,在您的情况下,sin 函数的输入参数 x
等于 2*pi*fc*(n-L/2)
。然后可以将分母写成此 x
(pi*(n-L/2) = 0.5*x/fc
) 的函数,它为您提供 2*fc
乘以 sinc
的比例因子。这可以在这里说明:
builtin_sinc = 2*fc*sinc(2*fc*(n-L/2));
hold off; stem(n, my_sinc);
hold on; plot(n, builtin_sinc, 'rx');
随后您可以使用
获得相同的滤波器系数
filter_coeffs = (builtin_sinc .* win);
或直接
filter_coeffs = 0.5*sinc(2*fc*(n-L/2)) .* win;
为了设计滤波器(windowing 方法),我首先生成我的 sinc 函数,如下所示:
L = 20;
fc = 0.25;
n = (1:L)';
my_sinc = sin(2*pi*fc*(n-L/2)) ./ (pi*(n-L/2));
my_sinc(L/2) = 2*fc;
然后我申请window:
win = blackman(L, 'symmetric');
filter_coeffs = (my_sinc .* win);
第一步可以用Matlab内置的sinc()
函数完成吗?
当然可以。您可以使用内置的 sinc
函数来获得与您在 my_sinc
中计算的结果完全相同的结果。由于 sinc(x) = sin(pi*x)/(pi*x)
,在您的情况下,sin 函数的输入参数 x
等于 2*pi*fc*(n-L/2)
。然后可以将分母写成此 x
(pi*(n-L/2) = 0.5*x/fc
) 的函数,它为您提供 2*fc
乘以 sinc
的比例因子。这可以在这里说明:
builtin_sinc = 2*fc*sinc(2*fc*(n-L/2));
hold off; stem(n, my_sinc);
hold on; plot(n, builtin_sinc, 'rx');
随后您可以使用
获得相同的滤波器系数filter_coeffs = (builtin_sinc .* win);
或直接
filter_coeffs = 0.5*sinc(2*fc*(n-L/2)) .* win;