%% Frequency Response from Transfer Function
% Compute and display the magnitude response of the third-order IIR lowpass filter described by the following transfer function:
% H(z)=\frac{0.05634(1+z^{-1})(1-1.0166z^{-1}+z^{-2})}
%             {(1-0.683z^{-1})(1-1.4461z^{-1}+0.7957z^{-2})}.
% Express the numerator and denominator as polynomial convolutions. Find the frequency response at 2001 points spanning the complete unit circle.

b0 = 0.05634;
b1 = [1  1];
b2 = [1 -1.0166 1];
a1 = [1 -0.683];
a2 = [1 -1.4461 0.7957];

b = b0*conv(b1,b2);
a = conv(a1,a2);

[h,w] = freqz(b,a,'whole',2001);

%
% Plot the magnitude response expressed in decibels.

plot(w/pi,20*log10(abs(h)))
ax = gca;
ax.YLim = [-100 20];
ax.XTick = 0:.5:2;
xlabel('Normalized Frequency (\times\pi rad/sample)')
ylabel('Magnitude (dB)')

% Copyright 2015 The MathWorks, Inc.