Filters are systems designed to modify the frequency content of their input signals. There are five major classes of filters:
In filter design programs, the maximum frequency is usually taken to be 1. So the allowable range of ``normalized frequencies'' is from 0 to 1.
The fir1
command will design lowpass filters, given the cutoff
frequency and the filter order . The cutoff frequency for a lowpass filter
is defined as the frequency above which all other frequencies will be removed.
As mentioned above, its allowable range of values is between 0 and 1,
corresponding to 0 and .
The filter order determines the ``goodness'' of the filter. Ideally, a filter would pass all frequencies below the cutoff frequency, and reject all frequencies above the cutoff, as in Figure 2. Since these filters are nonideal ones, the transition band, or the range of frequencies over which the filter stops passing frequencies and begins rejecting them instead, will not be as steep. A higher order filter will have a smaller transition band, but at the expense of higher computational cost. There is no such thing as a free lunch.
Figure 2: Ideal lowpass filter frequency response with cutoff frequency .
The fir1
command returns two vectors labeled and :
>> [b,a] = fir1(order, fc)To view the results of
fir1
, use the freqz
command:
>> freqz(b,a)This will plot the filter frequency response in magnitude and in phase against the ``normalized frequencies'' from 0 to 1, which can be appropriately translated into actual frequencies.
To actually use the filter that you have designed, try the Matlab command:
y=filter(b,a,x)where is the input sequence and is the output sequence. If you compare the DFT of the input sequence to the DFT of the output sequence , you will find that is the product of and the frequency response of the filter.