Source:
Design of the% notch filter
The transfer function of the% notch is
% B (1/z) (Z-exp (J*2*PI*F0)) * (Z-exp (-J*2*PI*F0))
%H (z) =--------=--------------------------------------------
% A (1/z) (Z-a*exp (J*2*PI*F0)) * (Z-a*exp (-J*2*PI*F0))
% of whichF0 is the frequency at which the notch filters out the signal,A is a parameter associated with the notch depth,A larger, deeper depth.
%
% of known signals50Hz Power frequency interference, the signal isX=sin (2*pi*50*n*ts) +sin (2*pi*125*n*ts);
% requires filter by notch filter50Hz interference Signal
% parameter setting: sample ratets=0.001s, sample length:512 pips
Clf;clear;
% Set Initial value
f0=50;
ts=0.001;
Fs=1/ts;
nlen=512;
n=0:nlen-1;
Design of the% notch filter
Apha=-2*cos (2*pi*f0*ts);
beta=0.96;
B=[1 APHA 1];
A=[1 Apha*beta beta^2];
Figure (1);
FREQZ (B,A,NLEN,FS);% notch feature display
X=sin (2*pi*50*n*ts) +sin (2*pi*125*n*ts);% original signal
Y=dlsim (b,a,x);% notch filter processing
% The frequency domain transform of the signal.
Xfft=fft (X,nlen);
Xfft=xfft.*conj (XFFT)/nlen;
Y1=fft (Y,nlen);
Y2=y1.*conj (y1)/nlen;
Figure (2);% filter before and after the signal comparison.
Subplot (2,2,1);p lot (n,x);
Xlabel (' time (s) '); Ylabel (' amplitude '); title (' Input Signal ');
Subplot (2,2,3);p lot (n,y);
Xlabel (' time (s) '); Ylabel (' amplitude '); title (' Filter output ');
Subplot (2,2,2);p lot (n*fs/nlen,xfft), axis ([0 fs/2 min (xfft) max (XFFT)]), grid;
Xlabel (' Frequency (Hz) '); Ylabel (' Magnitude (DB) '); title (' Input Signal ');
Subplot (2,2,4);p lot (n*fs/nlen,y2), axis ([0 fs/2 min (y2) max (y2)]), grid;
Xlabel (' Frequency (Hz) '); Ylabel (' Magnitude (DB) '); title (' Filter output ') ;
Design of "matlab" Notch device