Signals and Systems - Electrical Engineering

(avery) #1
11.6 Realization of Discrete Filters 689

n = 0:N;
if wind == 1
window = boxcar(N + 1);
disp(‘ ***** RECTANGULAR WINDOW *****’)
elseif wind == 2
window = hanning(N + 1);
disp(‘ *****HANNING WINDOW *****’)
elseif wind == 3
window = hamming(N + 1);
disp(‘ ***** HAMMING WINDOW *****’)
else
window = kaiser(N + 1,4.55);
disp(‘ ***** KAISER WINDOW *****’)
end
% calculation of ideal impulse response
den = pi∗(n - N/2);
num = sin(wc*den);
% if N even, this prevents 0/0
if fix(N/2) == N/2,
num(N/2 + 1) = wc;
den(N/2 + 1) = 1;
end
b = (num./den).∗window’;
% frequency shifting
[H,w] = freqz(b,1,256); %% low-pass
if wo>0 & wo<1,
b = 2∗b.*cos(wo∗pi∗(n - N/2))/H(1);
elseif wo == 0,
b = b/abs(H(1));
elseif wo == 1;
b = b.∗cos(wo∗pi∗(n - N/2));
end

MATLAB provides the functionfir1to design FIR filters with the window method. As expected, the
results are identical for eitherfir1andfir. The reason for writingfiris to simplify the code and to
show how the modulation property can be used in the design of filters different from low-pass
filters. n

11.6 Realization of Discrete Filters


The realization of a discrete filter can be done in hardware or in software. In either case, the imple-
mentation of the transfer functionH(z)of a discrete filter requires delays, adders, and constant
multipliers as actual hardware or as symbolic components. Figure 11.25 depicts the operation of
each of these components as block diagrams.

Free download pdf