Digital Filters
31
a = A\b;
a1 = a(1)
a0 = a(2)
w = [0:0.01:pi];
%% frequency response of the length-3 FIR filter
H = a0 + a1*exp(-i*w) + a0*exp(-i*2*w);
%% frequency response of the length-11 FIR filter
%% (cascade of 5 length-3 filters)
H11 = H.^5;
subplot(2,2,1); plot(w, 20*log10(abs(H11)));
xlabel('frequency [rad/sample]');
ylabel('magnitude [dB]');
axis([0,pi,-90,0]); grid;
eval(myreplot);
pause;
%% pole-zero plot
%% In Matlab, it can be done with
%% the single line:
%% zplane(roots([a0,a1,a0]),0);
w_all = [0:0.05:2*pi];
subplot(2,2,2); plot(exp(i*w_all), '.'); hold on;
zeri = roots([a0, a1, a0]);
plot(real(zeri),imag(zeri), 'o');
plot(0,0, 'x'); hold off;
xlabel('Re');
ylabel('Im');
axis ([-1.2, 1.2, -1.2, 1.2]);
if (plat=='matlab') axis ('square'); end;
eval(myreplot);
pause;
k = [0:10]'; kernelw = exp(-i*k*w);
aa = H11 / kernelw
subplot(2,2,3); plot([0:10],real(aa),'+');
xlabel('samples');
ylabel('h');
grid;
axis;
eval(myreplot);
aa2 = conv([a0 a1 a0],[a0 a1 a0]);
aa3 = conv(aa2,[a0 a1 a0]);
aa4 = conv(aa3,[a0 a1 a0]);
aa5 = conv(aa4,[a0 a1 a0])
%% verify that aa5 = aa: by composition of convolutions we get
%% the same length-11 filter
In the first couple of lines the script converts the specifications for a length-3
FIR filter. Then, this elementary filter is designed using the technique previously
presented in this section. The frequency response H
11
of the length-11 filter is ob-
tained by exponentiation of the length-3 filter to the fifth power. The magnitude
Next Page >>
<< Previous Page
Back to the Table of Contents