%Example 8-1: Half-band filter.
clear;Z=exp(j*pi*[2:6]/4);
P=0.8*exp(j*pi*[1 2 -1 -2]/4);
P=[P 0.6];W=linspace(0,pi,1000);
B=poly(Z);A=poly(P);Z1=exp(j*W);
H=polyval(B,Z1)./polyval(A,Z1);
H=H/H(1);%Normalize dc gain to 1.
subplot(221),plot(W,abs(H)),axis tight
subplot(222),zplane(B,A),
axis([-1.5 1.5 -1.5 1.5])