%% Example 4.15 CDF(2,2) filters
%
% The CDF(2,2) analysis filters have z-transforms H_0 and H_1 given by
%

syms z
H0 = sqrt(2)*(-z^2+2*z+6+2*z^(-1)-z^(-2))/8
H1 = sqrt(2)*(-z^2+2*z-1)/4

%
% The frequency response is given by substituting z=e^{i\omega } and then taking the absolute value.
%

syms w 'real'
absH0 = abs(subs(H0,z,exp(i*w)))
absH1 = abs(subs(H1,z,exp(i*w)))

%
% Here are the plots of the frequency response.
%

fplot(absH0,[0 pi])
hold on
fplot(absH1,[0 pi])
axis([0 pi 0 1.7])
xticks([0 pi/4 pi/2 3*pi/4 pi])
xticklabels({'0','.25','.5', '.75', '1'})
yticks([0 .5 1 1.5])
xlabel('frequency \omega (multiples of \pi)')
annotation('textarrow',[0.51 0.63],...
    [0.56 0.60],'String','crossover point');
annotation('textarrow',[0.35 0.48],...
    [0.76 0.83],'String','lowpass filter');
annotation('textarrow',[0.54 0.44],...
    [0.26 0.35],'String',{'highpass filter'});
title('Frequency response of CDF(2,2) analysis filters')