%% Example 4.16 Frequency response of  CDF(3,1) filters
%
% I write the absolute values of the z-transforms of the filters as functions of the frequency \omega. For the analysis filters I have:

syms w
absHlow = abs(cos(3*w/2)-3*cos(w/2))/sqrt(2)
absHhigh = abs(sqrt(2)*(sin(3*w/2)-3*sin(w/2))/4)
W = 0:0.001:pi;
absH0 = @(w) eval(vectorize(absHlow))
absH1 = @(w) eval(vectorize(absHhigh))

%
% For the synthesis  filters I have:

absGlow = sqrt(2)*abs(cos(3*w/2)+3*cos(w/2))/4
absGhigh = abs((sin(3*w/2)+3*sin(w/2))/sqrt(2))
W = 0:0.001:pi;
absG0 = @(w) eval(vectorize(absGlow))
absG1 = @(w) eval(vectorize(absGhigh))

%

figure
plot(W,absH0(W))
hold on
plot(W,absH1(W))
axis([0 pi 0 2.5])
xlabel('frequency \omega (multiples of \pi)')
title('Frequency response, CDF(3,1) analysis filters')
annotation('textarrow',[0.3729 0.3033],[0.5716 0.6502],'String','lowpass analysis')
annotation('textarrow',[0.6193 0.7497],[0.5035 0.5059],'String','crossover point')
annotation('textarrow',[0.3568 0.4104],[0.2454 0.1859],'String','highpass analysis')

%

figure
plot(W,absG0(W))
hold on
plot(W,absG1(W))
axis([0 pi 0 2.5])
xlabel('frequency \omega (multiples of \pi)')
title('Frequency response, CDF(3,1) synthesis filters')
annotation('textarrow',[0.4943 0.4604],[0.6253 0.7444],'String','highpass synthesis')
annotation('textarrow',[0.5265 0.4372],[0.4253 0.3753],'String','lowpass synthesis')
annotation('textarrow',[0.389 0.2961],[0.511 0.511],'String','crossover point')

%
% Notice: For the analysis filters, the crossover point is at a fairly high frequency. Most of the midrange frequency goes through the lowpass channel. The highpas filter vanishes to order 3 at 0 and the lowpass filter vanishes to order 1 at pi. This behavior is reversed for the synthesis filter.