필터 지우기
필터 지우기

having a problem using an iir notch filter

조회 수: 19 (최근 30일)
kobi
kobi 2014년 1월 4일
답변: kobi 2014년 1월 6일
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
% code
end
*t=0:0.0005:0.5; % fs=2000Hz
x=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 filter
wo = 50/(2000/2); bw = wo/35;
[b,a] = iirnotch(wo,bw);
fvtool(b,a);
%signal after filterization
figure;
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 get
figure;
y=sin(2*pi*70*t);
plot(t,y);
title('A 70 Hz sinus - for comparison');*
thanks a lot

채택된 답변

Wayne King
Wayne King 2014년 1월 5일
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.

추가 답변 (3개)

Wayne King
Wayne King 2014년 1월 4일
It is working, you just need to tweak the parameters a bit to get better results.
nyquist = 2000/2;
w0 = 50/nyquist;
bw = w0/20;
[b,a] = iirnotch(w0,bw,20);
y = filter(b,a,x);
ydft = fft(y);
plot(abs(ydft))

kobi
kobi 2014년 1월 4일
hi and thanks for the immidiate answer. I saw that you changed the Q factor. What its affect about ? in addition, when i changed the number to 20 (as you advised me) i didn't get a real 70 Hz sinus as you can see in the attached pictures.... What can i do to make it exactly the same ? what parameter should i need to change ?
thanks a lot!

kobi
kobi 2014년 1월 6일
O.K
I changed this part of code to yours and as you told me, i'v got a 70Hz sinwave with a reduction.
some question about the plot after filtering :
1. Does the reduction comes from the filter itself ? how can i solve it ? by multyplying it to the gain i need to get (1 - -1) ?
2. Why am I getting in the begining of the filtered plot something wierd (0-0.025 sec) ?

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by