MATLAB Answers

0

Designing a Notch Filter

Asked by Sri Srujan Gollapudi on 19 Oct 2019 at 1:41
Latest activity Edited by Star Strider
on 19 Oct 2019 at 3:55
Hello,
I'd like to design a notch filter with Fs=22050Hz, frequency=60Hz sinusoidal signal. Can someone please tell me what parameters to pass inside the notch filter function?
Also, I have a voice signal saved as .wav file in my computer, and I want to mix it with the above 60Hz sine signal. Can someone help me with both my queries? I've been trying a few ways, but couldn't find the result.
Thanks

  0 Comments

Sign in to comment.

2 Answers

Answer by Sulaymon Eshkabilov on 19 Oct 2019 at 1:46

% The signal processing toolbox of MATLAB has:
iirnotch()
% Import your wav file with:
[y,Fs] = audioread('AUDIO_FIle.wav');
%
Good luck.

  1 Comment

Thanks for the response, but can you tell me what parameters I need to pass inside iirnotch() with Fs and notch frequncy given.
Thanks

Sign in to comment.


Star Strider
Answer by Star Strider
on 19 Oct 2019 at 3:03
Edited by Star Strider
on 19 Oct 2019 at 3:55

EDIT — (19 Oct 2019 at 3:55)
Or, if you want to do it without the filter design GUI:
Fs = 2250;
Fn = Fs/2;
Wp = [59 61]/Fn; % Stopband Frequency (Normalised)
Ws = [58 62]/Fn; % Passband Frequency (Normalised)
Rp = 1; % Passband Ripple
Rs = 60; % Passband Ripple (Attenuation)
[n,Wp] = ellipord(Wp,Ws,Rp,Rs); % Elliptic Order Calculation
[z,p,k] = ellip(n,Rp,Rs,Wp,'stop'); % Elliptic Filter Design: Zero-Pole-Gain
[sos,g] = zp2sos(z,p,k); % Second-Order Section For Stability
figure
freqz(sos, 2^18, Fs) % Filter Bode Plot
set(subplot(2,1,1), 'XLim',[0 100])
set(subplot(2,1,2), 'XLim',[0 100])
signal_filt = filtfilt(sos, g, signal); % Filter Signal
Note that I call the signal you want to filter ‘signal’ here.

  0 Comments

Sign in to comment.