2024 Fall Computer Assignment 2
2024 Fall Computer Assignment 2
Computer Assignment 2
Due: 15:00, November 19th (Tuesday), 2024
Please turn in your work to eeclass by 15:00. Late submission will receive no credit.
1. (25%) Let
( − 2) n , 0 n 3
h[n] =
0, otherwise
(a) Write your own convolution function to compute y[n] = x[n] h[n] and plot the result. Please create
a new function file named “my_conv” to do this work. (15%)
(b) Repeat previous problem by using AI tools, e.g. ChatGPT. Compare the result with your own
convolution function. For example, time consuming, syntax, and so on. (5%)
(c) Use MATLAB built-in function conv() to compute and plot y[n] again. (5%)
2. (35%) Given a square wave S ( t ) in the following figure, the Fourier series representation for the
square wave is
N
4 1
f (t ) =
n =1,3,5,... n
sin ( n t )
Hint
% square wave
t = linspace(0,2*pi,500)';
y = square(t);
t_approx = 0:0.01:2;
square_approx = … (your code)
plot(t/pi,y,'k--','LineWidth',3);
% hold on
% plot(t_approx, square_approx)
% hold off
subplot, and discuss your results. [Hint: you can set t_approx = 0:0.01:2, and overlap f ( t ) with the figure
3. (40%) When we dial a telephone number, a dual-tone multi-frequency signaling pitch consisting of two
simultaneous pure tone sinusoidal frequencies will be produced once a single key is pressed. For
example, pressing the key '1' will result in a sound composed of both a 697 and a 1209Hz tone.
(a) Please load the audio file ‘PhoneSound.wav’ and plot the audio signal x .
[Hint: you can use the build-in function audioread, in which you can get the sampling rate f s and
audio signal x . The sampling rate indicates the number of samples taken per second. The audio
signal is composed of 10 telephone button tones.] (10%)
(b) Please divide x into 10 segments having equal length (0.5 sec), and plot the power spectral density
for each segment. [Hint: you can use MATLAB built-in function fft().] (25%)
(c) From each plot, you will find two pitches and please tell what number was dialed based on the definitions
provided in the above table. Please answer what phone number was dialed? (5%)