2016-12-03 1429 views
1

我正在设计一个滤波器来消除一段音频中的噪音。我发现噪声频率位于频谱中的745至1965赫兹,但我不知道如何使多个陷波滤波器去除这两个特定频率如何在MATLAB中制作多陷波滤波器?

这是我的代码。我只能删除音频中的一个频率。有没有什么办法让MATLAB中的两个过滤器卷积?

%Reading first sample file 
[x1,fs1] = audioread('sample.wav'); 

%Creating the time span for the file 
t1=(0:length(x1)-1)/fs1; 

%Creating the frequency span for the file 
k1 = 0:length(x1)-1; 
f1=k1*fs1/length(x1); 
wg=[744.5*2/fs1 745.5*2/fs1 ]; 

%Creating filter 
[b1,a1] = butter(2,wg,'stop'); 

%Performing filtering on file 
x1f = filter(b1,a1,x1); 

回答

0

正如您已经提到的,您必须将两个过滤器进行卷积以合并它们。这可以使用conv函数完成。

% Design first filter 
wg1 = [744.5*2/fs1, 745.5*2/fs1]; 
[b1,a1] = butter(2,wg1,'stop'); 

% Design second filter 
wg2 = [1964.5*2/fs1, 1965.5*2/fs1]; 
[b2,a2] = butter(2,wg2,'stop'); 

% Convolve filters 
a0 = conv(a1, a2); 
b0 = conv(b1, b2); 

% Plot filter 
freqz(b0, a0, 4096, fs1); 

bode plot of designed filter

+1

太感谢你了,我只是想CONV功能比较滤波后的信号,它的作品! –