Professional Documents
Culture Documents
EE325 Signals & Systems II Lab #1 Filtering Report Due: M1B: Tuesday, January 25 3:45pm M1D: Thursday, January 27 3:45pm Via Gradescope
EE325 Signals & Systems II Lab #1 Filtering Report Due: M1B: Tuesday, January 25 3:45pm M1D: Thursday, January 27 3:45pm Via Gradescope
EE325 Signals & Systems II Lab #1 Filtering Report Due: M1B: Tuesday, January 25 3:45pm M1D: Thursday, January 27 3:45pm Via Gradescope
Lab #1 Filtering
Report due:
M1B: Tuesday, January 25 3:45pm1
M1D: Thursday, January 27 3:45pm
via gradescope
Portions of this lab were adapted/taken from “Computer Explorations in Signals and Systems
Using Matlab” second edition, by Buck, Daniel, and Singer.
Introduction
This lab will introduce you to some of the basic commands for filtering discrete-time signals in
Matlab, as well as give you some exposure to how digital signal processing can be used to
process an audio signal. In both parts of this lab, it is important to note that the audio signals are
discrete-time signals acquired through the process of sampling a continuous-time audio signal,
the filtering operation takes place in the discrete-time domain, and the discrete-time audio signal
is being reconstructed to a continuous-time audio signal when you play the file on your speakers.
We are thus implementing a discrete-time processing of a continuous-time signal as discussed in
Section 7.4 of the textbook.
Before Lab
It would strongly behoove you to have completed the tutorials in the handout included with this
lab on the Matlab commands filter (Section 2.2) and freqz (Section 3.2) if you are not
familiar with those functions. You do not need to submit your solutions to those tutorials, but
you will need to use those two functions to complete the remainder of this lab.
This lab will require the use of Matlab and the Signal Processing Toolbox. You can manage
add-ons by Clicking on the Add-Ons button on the Home tab in the Matlab Command window.
Search for Signal Processing Toolbox and follow the instructions to install it.
Lab
Complete the following problems and write up your individual solutions in the prescribed lab
format. You may include your code in line to your report or you may submit your Matlab code
as a .pdf with comments clearly indicating which portion of the lab the code corresponds to.
1 For consistency in canvas and gradescope, a single due date and time will be specified as the later of the two lab
sections, i.e., Thursday at 3:45pm. It is the students’ responsibility to submit their lab reports by the beginning
of their registered lab section. Tuesday lab section students are still expected to submit their lab reports by
Tuesday at 3:45pm.
1
Read Happy.wav into variable x and Happy_echo.wav into variable x_echo using the
Matlab command audioread. When reading in these two wave files, also read in the sample
frequency into variables fs1 and fs2. As an example, this can be done as shown below:
What is the sampling frequency of each signal? What is the length of each signal in samples and
seconds? Include answers to these questions in your lab report.
To listen to these signals, you can use the Matlab command sound as shown below:
sound(x,fs1);
sound(x_echo,fs2);
If the sound command does not work, you can alternatively use the Matlab command
audiowrite as shown below:
audiowrite('sound1.wav', x, fs);
Then you can listen to the sound file sound1.wav in another audio player on your computer.
Part Id: Define Full Transfer Function (Echo and Echo Cancellation)
Y (e j Ω)
Next find the full transfer function . Show your work and include this in your lab report.
X (e j Ω)
2
jΩ
Y (e ) X ech o ( e j Ω ) Y ( e j Ω )
*** Note that jΩ
= jΩ jΩ .
X (e ) X (e ) X ec h o ( e )
Is this transfer function equivalent to the echo cancellation that is claimed? Note that if we
successfully canceled the echo, we would expect y [ n ] =x [ n ]. Show your work and include this in
your lab report.
After constructing the feedback and feedforward vectors, filter x_echo through the echo
cancellation filter defined by filter coefficient vectors a and b using the command filter.
Listen to output. Comment on what you hear. If you have implemented the echo cancellation
filter correctly, the output should be a very clear signal almost identical to the clean signal x. If
that is not the case, you have not defined vectors a and/or b correctly.
What happens if don’t get the delay quite right? e.g., even off by one sample. Discuss your
results and include your answers in your lab report.
Here b and a are the feedforward and feedback coefficients, respectively, that define the
Butterworth filter. The parameter n is the order of the filter, Wn specifies the normalized cutoff
frequency, and ftype specifies the type of filter you want to design. The default is lowpass, so
you could either specify 'low' or leave the type blank, but for a highpass filter, you would
specify 'high' (with the apostrophes).
3
In this lab, use an order n of 9, and choose a cutoff frequency Wn of 0.1 (corresponding to a
cutoff frequency of Ωc =0.1 π ) for the lowpass filter and Wn of 0.3 (corresponding to a cutoff
frequency of Ωc =0.3 π ) for the highpass filter. In order to avoid confusion, call the coefficients
of your lowpass filter a_lp and b_lp and call the coefficients of your highpass filter a_hp and
b_hp.
Now that we have created the lowpass and highpass filter coefficients, use these as input to the
freqz command to plot the frequency response for each of the filters. Be sure to title your
plots. Do these filters have a frequency response consistent with what you expect for a lowpass
and highpass filter? Do these filters appear to have their cutoff frequency in the specified
location ( Ωc =0.1 π for the lowpass and Ωc =0.3 π for the highpass)? Be careful about
units on both axes when interpreting the frequency responses. Include the frequency response
plots in your report.
Now vary the cutoff frequencies of each Butterworth filter and comment on what you notice.
Discuss your results and include your answers in your lab report.