%Example 8-2: Notch filter to 
%eliminate 1 of 2 sinusoids.
f1=125;f2=200;fs=1000;aa=0.9;
N=1:50;%Computation interval
M=[31:50];%Display interval
W1=2*pi*f1/fs;
W2=2*pi*f2/fs;
X=sin(W1*N)+sin(W2*N);
B=[1 -2*cos(W2) 1];
A=[1 -2*aa*cos(W2) aa*aa];
Y=filter(B,A,X);
subplot(221),stem(M,X(M))
subplot(222),stem(M,Y(M))
W=linspace(-1,1,1000);
Z=exp(j*pi*W);
H=polyval(B,Z)./polyval(A,Z);
subplot(223),plot(W,abs(H))
subplot(224),zplane(B,A)