# Digital Signal Processing with Field Programmable Gate Arrays

Chapter03 - Home
Exercises: 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - 21 - 22 - 23 - 24 - 25 - 26 - 27 - 28 - 29 - 30

Exercise. This is the solution to exercise 3.1 in the book.

Solution. We can use the following Matlab script to design the Kaiser window filter:

D = fdesign.lowpass(Fp,Fst,Ap,Ast,400,500,3,48,2000);
H = design(D,kaiserwin);
%design(D,’kaiserwin’); % shows the filter figure
filter_coeffs=get(H,Numerator);
display([Filter length =  sprintf(%d,length(filter_coeffs))]);
% get the magnitude frequency response
h = freqz(filter_coeffs);
% find the ripples in interval 0..400 Hz with Fs/2=1000 Hz
magnitude=abs(h(1:floor((400/1000)*length(h))));
maxripple=max(abs(magnitude-1));
display([Max absolute ripple =  sprintf(%.4f, maxripple)  ( sprintf(%.4f,20*log10(maxripple+1.0))  dB)]);

In this case the filter length is 58. We can also generate the filter in Matlab using fdatool as suggested:

In this case the filter length is 57. In either case the absolute passband ripple and the maximum absolute passband ripple occurs at $\approx 365$ Hz with magnitude 0.03 dB.

We can generate the equiripple filter using the following Matlab script:

D = fdesign.lowpass(Fp,Fst,Ap,Ast,400,500,3,48,2000);
H = design(D,equiripple);
%design(D,’equiripple’); % shows the filter figure
filter_coeffs=get(H,Numerator);
display([Filter length =  sprintf(%d,length(filter_coeffs))]);
% get the magnitude frequency response
h = freqz(filter_coeffs);
% find the ripples in interval 0..400 Hz with Fs/2=1000 Hz
magnitude=abs(h(1:floor((400/1000)*length(h))));
maxripple=max(abs(magnitude-1));
display([Max absolute ripple =  sprintf(%.4f, maxripple)  ( sprintf(%.4f,20*log10(maxripple+1.0))  dB)]);

This produces the following:

In this case the filter length is 29 and the passband ripples are equal magnitude of 1.29 dB.