The next step is to apply our Kaiser window to the ``desired'' impulse response, where ``desired'' means a time-shifted (by 1/2 sample) and bandlimited (to introduce transition bands) version of the ``ideal'' impulse response in (4.22). In principle, we are using the frequency-sampling method (§4.4) to prepare a desired FIR filter of length as the inverse FFT of a desired frequency response prepared by direct Fourier intuition. This long FIR filter is then ``windowed'' down to length to give us our final FIR filter designed by the window method.
If the smallest transition bandwidth is
Hz, then the FFT size
. Otherwise, there may be too much time
aliasing in the desired impulse response.5.10 The only non-obvious
part in the matlab below is ``
.^8'' which smooths the taper to
zero and looks better on a log magnitude scale. It would also make
sense to do a linear taper on a dB scale which corresponds to
an exponential taper to zero.
H = [ ([0:k1-2]/(k1-1)).^8,ones(1,k2-k1+1),... ([k1-2:-1:0]/(k1-1)).^8, zeros(1,N/2-1)];Figure 4.11 shows our desired amplitude response so constructed.
Now we inverse-FFT the desired frequency response to obtain the desired impulse response:
h = ifft(H); % desired impulse response hodd = imag(h(1:2:N)); % This should be zero ierr = norm(hodd)/norm(h); % Look at numerical round-off error % Typical value: ierr = 4.1958e-15 % Also look at time aliasing: aerr = norm(h(N/2-N/32:N/2+N/32))/norm(h); % Typical value: 4.8300e-04The real part of the desired impulse response is shown in Fig.4.12, and the imaginary part in Fig.4.13.
Now use the Kaiser window to time-limit the desired impulse response:
% put window in zero-phase form: wzp = [w((M+1)/2:M), zeros(1,N-M), w(1:(M-1)/2)]; hw = wzp .* h; % single-sideband FIR filter, zero-centered Hw = fft(hw); % for results display: plot(db(Hw)); hh = [hw(N-(M-1)/2+1:N),hw(1:(M+1)/2)]; % caual FIR % plot(db(fft([hh,zeros(1,N-M)]))); % freq resp plot
Figure 4.14 and Fig.4.15 show the normalized dB magnitude frequency response of our final FIR filter consisting of the nonzero samples of hw.