필터 지우기
필터 지우기

Create a Notch filter with low and high pass filters

조회 수: 11 (최근 30일)
Luke McDevitt
Luke McDevitt 2022년 12월 4일
댓글: Paul 2022년 12월 5일
I have been attempting to create a notch filter where I can specifiy the range of frequncies that will be filtered out. This is my best attempt:
[y,Fs] = audioread('africa-toto.wav');
notchfilt = highpass(y,1000,Fs) .* lowpass(y,100,Fs);
figure
freqz(notchfilt, 1, 2^16, Fs)
sound(notchfilt,Fs)
I'm not sure why but the resulting audio playback is very very grainy and doesnt remove the frequencies specified correctly.
  댓글 수: 1
Paul
Paul 2022년 12월 5일
Hi Luke,
Not sure why the outputs of highpass() and lowpass() would be multiplied. If anything, it looks like they should be added
% create some data
Fs = 5000;
rng(100);
y = randn(1024,1);
% DTFT of the input
[hy,wy] = freqz(y,1,2^16);
% the output and its DTFT
notchfilt = highpass(y,1000,Fs) + lowpass(y,100,Fs);
[hn,wn] = freqz(notchfilt,1,2^16);
figure
plot(wy/2/pi*Fs,[abs(hy) , abs(hn)]),grid
Having said, designing the bandstop filter directly is the way to go.

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2022년 12월 4일
Use the bandstop function, specifying 'ImpulseResponse','iir' for best results.
  댓글 수: 3
Luke McDevitt
Luke McDevitt 2022년 12월 4일
For anyone wondering this would be the new code:
(where 350 is the low cutoff and 6000 is the high cutoff)
[y,Fs] = audioread('africa-toto.wav');
bandstop(y,[350 6000],Fs,ImpulseResponse="iir",Steepness=0.95)
Star Strider
Star Strider 2022년 12월 4일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Filter Analysis에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by