我有一个复杂的频率信号(我已从时域转换)。现在我想在切断频率值的同时实现低通滤波器。有人可以建议我在不使用内置函数(过滤器)的情况下实现低通滤波器的最佳方法。
答案 0 :(得分:1)
我建议你看看Robert Bristow-Johnson的Audio-EQ-Cookbook,你可以建立很多过滤器。
让我们尝试按照公式建立一个LPF(低通滤波器),首先我建立一个信号测试(四个正弦波在200,500,700和1000Hz),FFT图:
现在应用方程式来切断200hz的频率
我的代码用于测试:
%Low pass filter example from RBJ EQ-Cookbook
N = 4096;
%Test signal
Fs=44100;
f1 = 200;
f2 = 500;
f3 = 700;
f4 = 1000;
signal1 = 0.9*sin(2*pi*f1/Fs*(0:N+1));
signal2 = 0.9*sin(2*pi*f2/Fs*(0:N+1));
signal3 = 0.9*sin(2*pi*f3/Fs*(0:N+1));
signal4 = 0.9*sin(2*pi*f4/Fs*(0:N+1));
%mix all signals
signal= signal1 + signal2 + signal3 + signal4;
%test signal end
%%Start Filter
%F0 - cut off Frequency above ??
F0 = 200;
Q=1;
g = 80;
A = sqrt (10^(g/20));
w0 = 2 * pi * F0/Fs;
c= cos(w0);
s = sin(w0);
alpha = sin(w0)/(2*Q);
b0 = (1 - cos(w0))/2;
b1 = 1 - cos(w0);
b2 = (1- cos(w0))/2;
a0 = 1 + alpha;
a1 = -2*cos(w0);
a2 = 1 - alpha;
x1 = 0;
x2 = 0;
y1 = 0;
y2 = 0;
b0 = b0 / a0;
b1 = b1 / a0;
b2 = b2 / a0;
a1 = a1 / a0;
a2 = a2 / a0;
%y = filtred signal
for j=1:length(signal),
y(j) = b0*signal(j) + b1*x1 + b2*x2 - a1*y1 - a2*y2;
x2 = x1;
x1 = signal(j);
y2 = y1;
y1 = y(j);
end