Professional Documents
Culture Documents
Lab 09-Design of Filters - 2: Create, Import, and Name A Signal
Lab 09-Design of Filters - 2: Create, Import, and Name A Signal
1 Objectives:
. This Lab provides a complete example of using the GUI-based interactive tools to design and
implement an FIR digital filter, apply it to a signal, and display signals and spectra.
window method.
2 Time Required: 3 hrs
.
3 Programming Language: MATLAB
.
4 Software Required:
. (a). MATLAB 7 or above
SPTOOL:
This section provides a complete example of using the GUI-based interactive tools to design and
implement an FIR digital filter, apply it to a signal, and display signals and spectra.
You can import an existing signal into SPTool, or you can create a new signal and edit and name
it in SPTool. In this step, you’ll create a new signal at the command line and then import it into
SPTool.
-10
-30
-40
-50
-60
-70
-80
0 0.5 1 1.5 2
Frequency (kHz)
2) Click to select the signal noise[vector] from the Signals list and click to select the filter
(named filt1[design]) from the Filters list, as shown below.
3) Press Apply to apply the filter filt1 to the signal noise. The Apply Filter dialog box is
displayed.
4) Name the new signal by clicking in the Output Signal field and typing blnoise.
5) Press OK.
The filter is applied to the selected signal. The new, filtered signal blnoise[vector] is displayed in
the Signals list.
1) Shift-click on the noise and blnoise signals in the Signals list of SPTool to select both signals.
2) Press View in the Signals panel.
The Signal Browser is activated and both signals are displayed in the main axes display area.
Initially, the noise signal covers up the bandlimited blnoise signal, but you can see that both
signals are displayed because the names of both signals are shown above the main axes display
area.
3) Click-and-drag in the Selection pop-up menu to select the blnoise signal.
The main axes display area is redisplayed. Now you can see the blnoise signal superimposed on
top of the noise signal. The signals are displayed in different colors in the main axes display area.
Notice that the color of the line in the Selection display changes to correspond to the color of the
signal that you’ve selected.
The signal that’s displayed in the Selection pop-up menu and in the Selection display is the
active signal. When you select Play, or use the rulers, the active signal is the one that is played or
measured.
4) To hear the active signal, select Play from the Options menu.
5) To hear the other signal, select it as in step 3 above (you can also select the signal by clicking
on it in the main axes display area). Select Play from the Options menu again.
6) You can also print the signals. To print both signals, select Print... from the File menu in the
Signal Browser.
Compare Spectra of Both Signals
You can get an idea of the frequency content of the two signals by displaying their power spectra
using the Spectrum Viewer, as described below:
1) Reactivate SPTool by selecting it from the Window menu of the Signal Browser.
2) Click on the noise[vector] signal in the Signals list of SPTool to select it.
3) Press Create in the Spectra panel. The Spectrum Viewer is activated, and a spectrum object
(spect1) corresponding to the noise signal is created in the Spectra list. The spectrum is not
computed or displayed yet.
4) Press Apply in the Spectrum Viewer to compute and display spect1. The spectrum of the noise
signal is displayed in the main axes display area. Notice that the spectrum’s signal identification
information, including its name, its type, and its sampling frequency, is displayed above the
Parameters panel, and the spectrum’s name is displayed both above the
main axes display area and in the Selection pop-up menu.
5) Reactivate SPTool by selecting it from the Window menu in the Spectrum Viewer.
6) Click on the blnoise signal in the Signals list of SPTool to select it.
7) Press Create in the Spectra panel. The Spectrum Viewer is again activated, and a spectrum
object (spect2) corresponding to the blnoise signal is created in the Spectra list. The spectrum is
not computed or displayed yet.
8) Press Apply in the Spectrum Viewer to display spect2. The spectrum of the blnoise signal is
displayed in the main axes display Area. The new spectrum’s signal identification information,
including its name, its type, and its sampling frequency, is displayed above the Parameters panel,
and the spectrum’s name is displayed both above the main axes display area and in the Selection
pop-up menu.
9) Reactivate SPTool again, as in step 5 above.
10) Shift-click on spect1 and spect2 in the Spectra list to select them both.
11) Press View in the Spectra panel to reactivate the Spectrum Viewer and display both spectra
together.
12) To select one of the spectra for measuring or editing, use the Selection pop-up menu, or click
on the spectrum in the main axes display area.
13) You can also print these spectra by using the print option.
The most common method of IIR filter design is based on the bilinear transformation of a
prototype analog transfer function. The analog transfer function is usually one of the following
types: Butterworth, Type 1 Chebyshev, Type 2 Chebyshev, and elliptic transfer functions. The
difference between these filter types can be explained by considering the lowpass filter. The
Butterworth lowpass transfer function has a maximally-flat magnitude response, that is, and a
monotonically decreasing magnitude response with increasing frequency. TheType 1 Chebyshev
lowpass transfer function has an equiripple magnitude response in the passband and a
monotonically decreasing magnitude response with increasing frequency outside the passband.
The Type 2 Chebyshev lowpass transfer function has a monotonically decreasing magnitude
response in the passband with increasing frequency and an equiripple magnitude response in the
stopband. Finally, the elliptic lowpass transfer function has equiripple magnitude responses both
in the passband and in the stopband.
The first step in the filter design process is to choose the type of filter approximation to be
employed and then to estimate the order of the transfer function from the filter specifications.
The MATLAB command for estimating the order of a Butterworth filter is
After the filter type has been selected and its order estimated, the next step is to determine the
transfer function of the filter. To this endMATLAB provides functions for all four types of
filters. For designing Butterworth digital lowpass or bandpass filters, the command is
[num,den] = butter(N,Wn)
where the input parameters N and Wn are determined through the use of the function buttord,
and the output is the vectors num and den containing, respectively, the coefficients of the
numerator and denominator polynomials of the transfer function in ascending powers of z−1. If
Wn is a scalar, butter returns a lowpass transfer function of order N, and if Wn is a two-element
vector, it returns a bandpass transfer function of order 2N. For designing a Butterworth digital
highpass filter of order N, the command is
[num,den] = butter(N,Wn,’high’)
whereas, the command
[num,den] = butter(N,Wn,’stop’) returns the transfer function of a Butterworth bandstop filter of
order 2N provided Wn is a two-element vector. For designing a Type 1 Chebyshev digital filter,
the commands are
[num,den] = cheby1(N,Rp,Wn)
[num,den] = cheby1(N,Rp,Wn,’filtertype’)
For designing a Type 2 Chebyshev digital filter, the commands are
[num,den] = cheby2(N,Rs,Wn)
[num,den] = cheby2(N,Rs,Wn,’filtertype’)
Finally, for designing an elliptic digital filter, the commands are
[num,den] = ellip(N,Rp,Rs,Wn)
[num,den] = ellip(N,Rp,Rs,Wn,’filtertype’)
A lowpass transfer function of order N is returned in each case if Wn is a scalar, and a bandpass
transfer function of order 2N is returned if Wn is a two-element vector. In each of the above
commands, filtertype is high for designing a highpass filter with Wn being a scalar, and filtertype
is stop for designing a bandstop filter with Wn being a two-element vector.
Write a Program that illustrates the design of a Butterworth bandstop filter and
Chebyshev type 2 bandpass filter.