Lab Engineering homework help

Can Somebody do this for me?

EE325 Signals & Systems II
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.

Part I: Echo cancellation using filter

Part Ia: Read in Audio Files
Download Happy.wav and Happy_echo.wav from the Lab #1 assignment on Canvas.

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:

[x, fs] = audioread(‘file.wav’);

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 Ib: Define Echo System
The echo signal can be modeled as xecho [n ]=x [n ]+αx [n−N ] where xecho [n ] is the signal with the
echo, x [n ] is the original non-echoed signal, α is the attenuation of the echo, and N is the time-
delay of the echo in samples. For this example, Happy_echo.wav corresponds to α=0.75
and N=5499, which corresponds to a delay of approximately 0.25 seconds (since f s=22050

Hz). Given this information, find the transfer function
Xecho (e

jΩ)

X (e

)
. Show your work and include

this in your lab report. Note—we are using Ω here as the discrete-time frequency variable to
be consistent with the material in textbook section 7.4. You have seen this variable before as
ω .

Part Ic: Define Echo Cancellation System
An echo cancellation system can be implemented as y [n]=xecho [n ]−αy [n−N ] where y [n] is the
output of the echo cancellation and xecho [n ] is given as above. Is this system FIR or IIR? How do

you know? Find the transfer function
Y (e

jΩ)

Xecho (e
jΩ)

. Show your work and include this in your lab

report.

Part Id: Define Full Transfer Function (Echo and Echo Cancellation)

Next find the full transfer function
Y (e

j Ω)

X (e
jΩ)

. Show your work and include this in your lab report.

2

*** Note that
Y (e

j Ω)

X (e

)
=
X echo (e

jΩ)

X (e

)

Y (e
jΩ)

Xecho (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.

Part Ie: Implement Echo Cancellation System
We now want to define the coefficients for the echo cancellation system to compute the output of

our LCCDE. Please take careful note that you are going to be implementing
Y (e

jΩ)

Xecho (e
j Ω)

here.

Our analytical computations with
Xecho (e

j Ω)

X (e

)
and

Y (e
j Ω)

X (e
jΩ)

were to demonstrate that the proposed

echo cancellation filter does indeed cancel the echo.

Using your transfer function
Y (e

jΩ)

Xecho (e
j Ω)

from part Ic, construct feedback vector a and feedforward

vector b. Be very careful about a: remember that the first index in a corresponds to a delay of
zero samples.

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.

Part II: Lowpass Filtering and Highpass Filtering

Part IIa: Define Butterworth Filters
A Butterworth filter is a specific non-ideal filter. You can define lowpass and highpass
Butterworth filters using the Matlab command butter using the code below as an example.

[b, a] = butter(n, Wn, type);

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.

Part IIb: Filter Audio Signal through Butterworth Filters
Filter the original Happy.wav signal (variable x) filter (for both the lowpass and highpass).
Listen to the output and comment on the effects of both filters. What do you notice?

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.

4

Looking for this or a Similar Assignment? Click below to Place your Order