Digital Signal Processing Reference
In-Depth Information
b=fir1(N,Wc)
b=fir1(N,Wc,'ftype')
b=fir1(N,Wc,'ftype',window)
These forms give the N
+ 1 samples of the unit impulse response of the lin-
ear phase FIR filter or the coefficients of its transfer function. Wc is the cutoff
frequency of the lowpass filter, and ftype is omitted; it is the cutoff of the high-
pass filter when 'ftype' is typed as 'high' .But Wc is a two-element vector
Wc=[W1 W2] , which lists the two cutoff frequencies, ω c 1 and ω c 2 ( ω c 2
ω c 1 ) ,
of the bandpass filter. (Use help fir1 to get details when there are multiple
passbands.) The term 'ftype' need not be typed. When 'ftype' is typed as
'stop' , the vector Wc represents the cutoff frequencies of the stopband filter.
If the filter is a lowpass, it becomes a type I filter when N as obtained from
remezord is even and it is type II filter when N is odd. Note that the frequency
response of type II filters has a zero magnitude at the Nyquist frequency, that is,
their transfer function has a zero at z
=− 1 and therefore is a polynomial of odd
order. The highpass and bandstop filters that do not have a zero magnitude at the
Nyquist frequency cannot be realized as type II filters. When designing a highpass
or bandstop filter, N must be an even integer, and the function fir1 automatically
increases the value of N by 1 to make it an even number if the output from
remezord is an odd integer. Since the program assumes real values for the
magnitude and zero value for the phase, we do not get types III and IV filters
from this type of frequency specification. The window by default is the Hamming
window in fir1 , but we can choose the rectangular (boxcar), Bartlett, triangular,
Hamming, Hanning, Kaiser, and Dolph-Chebyshev (chebwin) windows in the
function fir1 . After getting the coefficients of the FIR filter, we can find the
magnitude (phase and group delay also) of the filter to verify that it meets the
specifications; otherwise we may have to increase the value of N , or change the
values in the vector dev .
Example 5.9
Now that we have obtained all the input data needed to design a LP filter with
N
= [0 . 12 0 . 3], we
design the FIR filters with the Hamming window and the Kaiser window. So we
have four cases, discussed below.
The M-files for designing the four filters are given below, and the resulting
magnitude responses are shown in Figures 5.13-5.17.
It must be noted from Figure 5.9 that the magnitude of the filter designed by
the Fourier series method is 0.5 at ω c , whatever the window function used to
minimize the Gibbs overshoot. The order N
= 39 and ω c
= 0 . 3 and a BP filter with N
= 195 and ω c
= 39 for the lowpass filter, obtained
from the function remezord , is only an estimate that is very conservative because
it results in the magnitude response of the filter that does not meet the passband
error δ p
= 0 . 01 specified and used in that function. So we have to change the
value for the cutoff frequency ω c and the order N of the filter by trial and error
Search WWH ::




Custom Search