# MATLAB: Having a problem using an iir notch filter

filteringiir notch

hello everyone,
i want to filter 50 Hz sinus and therefore i implemented a notch filter such as shown in the help. i don'w know why it doesn't work. does everyone have a clue ? see also the attached file 'debuging' this is the program :
if true  % codeend*t=0:0.0005:0.5; % fs=2000Hzx=sin(2*pi*50*t)+sin(2*pi*70*t);figure;plot(t,x);title('Sum of sinuses - of 50Hz & of 70Hz ');% implementation of the notch filterwo = 50/(2000/2);  bw = wo/35;[b,a] = iirnotch(wo,bw);fvtool(b,a);%signal after filterizationfigure;g=filter(b,a,x);plot(t,g);title('The signal after removing its 50 Hz sinus');%figure of 70 Hz for comarison to what i need to getfigure;y=sin(2*pi*70*t);plot(t,y);title('A 70 Hz sinus - for comparison');*
thanks a lot

#### Best Answer

Kobi, did you also supply the optional Ab input argument as I did?
nyquist = 2000/2; w0 = 50/nyquist; bw = w0/20; [b,a] = iirnotch(w0,bw,20); y = filtfilt(b,a,x); plot(t,y);
From your output it does not appear that you did.
If you execute the above, you should see that is pretty much a clean 70-Hz sinewave with a reduction in amplitude.