Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

EEL3135: Lab 6

Summer 2022

Lab 6 Information

• The material in this section is informational.  Please read through the section as it helps you work on the lab exercises in the next section.   There may be code examples in this informational section.  You are welcome to copy-and-paste them to MATLAB to run the code, but no submission is needed on any test run.

Calculating DTFT in MATLAB

It is not hard to see that you may use the function freq resp you wrote in Lab 5 to calculate the DTFT of any finite-length signal (why?). Hereafter in this lab, rename the your freq resp

function in Lab 5 to dtft. That is,

X  =  dtft(x,w)

where x is the input signal vector, w is a (normalized radian) frequency vector, and X is the DTFT vector of x calculated at the frequencies specified in w.  For an infinite-length signal, we have to truncate it in order to use the function dtft to approximately calculate the DTFT of the signal.

Note that the “for-loop” method used in dtft is a computationally inefficient way to calculate the DTFT of a signal, as you will see in the later parts of the lab. We will talk about how to do DTFT calculations in a much more computationally efficient near the end of the semester.

Table of Discrete-Time Fourier Transform Pairs

Discrete-Time Fourier Transform   :   X(ej ) =    x[n]en

=−∞

Inverse Discrete-Time Fourier Transform   :   x[n] =  2π X(ej )ej n d

Dirac delta function that repeat every 2π    :   δ2π() =     δ( − 2πk)

 

x[n]

X(ej)

condition

anu[n]

1

1 ae j

|a| < 1

(n + 1)anu[n]

(n + r 1)! anu[n]

δ[n]

δ[n  n0]

x[n] = 1

u[n]

ej 0 n

1

(1 − ae j )2

1

(1 − ae j )r

1

e j n0

2πδ()

|a| < 1

|a| < 1

cos(0 n)

sin(0 n)

=−∞

 

x[n] =

  0   ,   |n| > N

 

 

 

j

 

=−∞

sin((N + 1/2))

 

 

 = sinc  

 

   1

X(ej   ) =         ,

   0   ,

X(ej) is periodic

0 ≤ || ≤ W

W < || ≤ π

 

 

Table of Discrete-Time Fourier Transform Properties

For each property, assume

x[n]  X(ej )   and   y[n]  Y (ej )

Property


Time domain     DTFT domain

Ax[n] + By[n]

x[n n0]

x[n]ej0 n

x [n]

x[−n]

x[n] ∗ y[n]

x[n]y[n]

x[n] x[n 1]

P−∞ x[k]

nx[n]

P|x[k]|2

Lab 6 Exercises

• Unless stated otherwise, you must submit your solutions to all the lab exercises in this section.

• Your laboratory solutions should be submitted on Canvas as a single PDF. The simplest way is to put your codes and answers for all the lab exercises in a single MATLAB Publisher script and use %% to separate the codes and answers for different exercises into different sections as described in the information section of Lab 1.

• Plot all magnitude spectrums in this lab in dB scale.

Exercise 6.1:

This exercise shows you how to carefully interpret the results obtained from your MATLAB function dtft, particularly for the cases of infinite-length signals.

Use the tables in the information section, or otherwise, to analytically determine the expressions of the DTFTs for the signals below.   Use your MATLAB function dtft to calculate and plot (magnitude and angle) the DTFTs.  For each signal, truncate its length to 10, if needed, when using your function dtft to calculate the DTFT. Compare your plot with the DTFT expression you obtain analytically. Do they match? Repeat the same MATLAB calculation of the DTFT and comparison with the analytic expression by truncating each signal to length 100 instead. Explain the effects of increasing the truncation length.

(a) x[n] = δ[n − 3]

(b) x[n] = (8/9)nu[n]

(c) x[n] = (−8/9)nu[n]

(d) x[n] = u[n] − u[n − 5]

(e) x[n] = cos((π/4)n)

Exercise 6.2:  (Nulling Filter)

This exercise shows you how to employ DTFT to analyze an audio signal corrupted by a sinusoidal interfering signal.   Specifically, you will examine the DTFT to determine the frequency of the sinusoidal interference and then use a nulling filter to remove the interference. The corrupted audio signal is provided in the WAV file corrupted wannabe .wav.

(a) Load corrupted wannabe .wav into MATLAB. Use your function dtft to calculate the DTFT

of the audio signal. Plot the magnitude of the DTFT. Hint: You should use a frequency vector that has at least 2000 points to calculate the DTFT so as to properly identify the interference frequency in part (b) below. It may take a minute or so to compute the DTFT.

(b) Identify the frequency of the sinusoidal interference. Give this frequency in normalized radian

frequency as well as continuous-time cyclic frequency. Hint: Remember from Exercise 6.1 what the magnitude plot of the DTFT of a sinusoid should look like. You may use “Tools →Data Tips” to identify the value of interference frequency from the DTFT magnitude plot. You may also use the MATLAB function find (see Lab 5) to more accurately determine the frequency of interest.

 

(c) Consider the following nulling FIR filter:

y[n] = x[n] − 2cos(0 )x[n − 1] + x[n − 2],                                        (1)

(d) Apply the nulling filter to the corrupted audio signal.  Listen to the filtered audio and save it to the WAV file filtered wannabe .wav.  Submit the WAV file.  Use your dtft function to calculate and plot the magnitude of the DTFT of the filtered audio signal.  Describe the differences between the DTFTs of the original audio and the output of the nulling filter, particularly with respect to the interference signal.

Exercise 6.3 (Extra credits:  +20 points):

This exercise is similar to Exercise 6.2. An audio signal (not the same as the one in Exercise 6.2) is corrupted by a very strong artificial noise (not a simple sinusoidal interference). You again need to use your dtft function to study the frequency contents of the corrupted audio signal, identify the frequency range of the noise components, and design a filter to remove the noise. The theory behind how to design a filter that can remove the noise here is a bit too advance for us.  Instead of going through the theory, this exercise shows you how to use a MATLAB filter design GUI to work out the required filter.

Load in the noisy audio signal from the WAV file what did he say .wav. Use your dtft function to calculate and plot the magnitude of the signal’s DTFT. Identify the frequency range of the noise. Express your answer in both normalized radian frequency and continuous-time cyclic frequency. To remove the noise in this case, you will need to employ a filter different than the nulling filter in Exercise 6.2. State what kind of filter (lowpass, highpass, bandpass) is needed to remove the noise. Determine the start and end frequencies of the passband and stopband of the filter.

MATLAB has a GUI filterDesigner that helps you design a filter.  Type filterDesigner in the command window to invoke the GUI. You may select the type of the filter that you want to design.  Based on your answer above, choose whether you want to design a lowpass, highpass, or bandpass filter. Choose FIR Equiripple. Choose the Filter Order to be Minimum order. Specify the sampling frequency, start and end frequencies of the passband and stopband. You will also need to specify the ripple tolerance in the passband (Apass) and the magnitude attenuation from the passband to stopband (Astop).   It suffices to choose Apass =  1 dB. You will need to choose a suitable value for Astop.  For example, Astop = 60 dB means that the value of the magnitude response in the stopband is 60 dB below that in the passband.  After specifying all the parameters, click the Design Filter button to generate the filter impulse response.  You can save the generated impulse response to your workspace by choosing “File →Export”, and then specifying Export  to  Workspace, Export  as  Coefficients, and setting Numerator to your choice of a variable name to hold the impulse response.  Click the Export button to export the impulse response to your workspace.

Use the GUI to design a filter that can remove the noise. Report all the parameters that you specify in the GUI. Export the impulse response of the filter to your MATLAB workspace. Apply this filter to the noisy audio signal. Listen to the filtered signal and save the filtered audio to the WAV file filtered what .wav. Submit the WAV file. Write down the sentence dictated in the audio file.  Use your dtft function to calculate and plot the magnitude of the DTFT of the filtered audio signal. Describe the differences between the DTFTs of the original audio and the output of the noise removal filter, highlighting what and how much noise components are removed by the filter.

Note that you may need to iterate the above filter design process a few times to generate a relatively clean and audible audio signal.