Starting from:

$30

ECE 4250 Assignment 1

ECE 4250
Assignment 1

General Instructions
The assignment submissions are via Canvas. There are two parts: a problem set and a coding
(programming) component. Your answers to the problems can be written up any way you want
(e.g., using Latex or scanning your handwritten answers). As long as we can read it, we will
grade it. For the programming part, you will code in Python 3, using Jupyter Notebook. Make
sure that all cell outputs are clearly visible before saving the notebook. Thus, we recommend
that you re-run your code after you are done editing. You should then print this file into a pdf.
For the coding component, please submit both the “.pdf” and “.ipynb” files. Please zip up all
your work into a single file and submit that.
Any acknowledgments of collaboration, answers to questions, comments to code or other notes
should all be included in your problem set answer sheet and/or Jupyter Notebook. General
guidelines regarding assignments apply. In other words, you can collaborate at the ideation/brainstorming stage, but whatever you submit should represent your own individual work. You are
not allowed to copy/paste others’ code/answers or work on same code with someone else. You
are not allowed to use functions outside of the Python Standard Library, unless specified otherwise or you have received permission to do so. Your code will be graded on readability,
executability, and accuracy. You are strongly advised to use detailed commenting that explains the algorithmic steps in your code. Explain every function and loop. Use piazza to ask
questions. Take advantage of TA and Instructor Office Hours to seek help.
Problem Set
Question 1. For each of the following systems, classify whether they are (i) linear or not, (ii)
time invariant or not, (iii) causal or not, and (iv) stable or not:
• y(n) = x(2 − n)
• y(n) = sign(x(n))
• y(n) = x(7n)
• y(n) = sin(x(n))
• y(n) = |x(n)|
1
Question 2. Show that the energy of a real-valued signal can be decomposed into the sum of
the energies of the even and odd parts of the signal.
Question 3. Consider a continuous-time sinusoid xa(t) with a period T0 = 1/F0. Assume this
signal is sampled at a rate of Fs = 1/Ts to produce a discrete-time signal x(n) = xa(nTs).
• What is the condition on Ts and T0 for x(n) to be periodic?
• If x(n) is periodic, what is its fundamental (baseline) period?
Question 4. Assume you are given an LTI system with a step response s(n), which is defined
as the output of the system when excited with (input) a step function u(n)? Can you derive
the expression for the output y(n) in terms of s(n) and an arbitrary input x(n)?
Question 5. Two discrete-time signals x(n) and y(n) are called orthonormal on an interval
[N1, N2], if
X
N2
n=N1
x(n)y

(n) = (
1, if x(n) = y(n), ∀n ∈ [N1, N2]
0, otherwise
Show that harmonically related signals: xk(n) = √
1
N
e
j2πkn/N are orthonormal on an interval of
length N. I.e,
N
X−1
n=0
xk(n)x

l
(n) = (
1, if k = l
0, otherwise
,
where 0 < k, l < N − 1 and N ≥ 2.
Programming Questions
1 Convolutions
Define the following signals
x =

3, 4, 1, 2, 5, 6, 7, 8, 2, 4

h =

1
4
,
1
4
,
1
4

a) Calculate the convolution between these two signals, x ∗ h, in time domain (don’t use any
libraries or built in functions besides addition and multiplication). Note that the convolution
of two signals of length N and M should be of size (N + M − 1).
b) Describe in words what this convolution does.
c) Convolutions are O(N2
) when computed in the time domain for two 1D signals of length
N. I.e., the physical resources (e.g., time) that are needed to convolve two 1D signals of the
same length are proportional to the square of the signal length. However, with a constant
filter like h, we can modify the process to make it O(N). Show how to do a convolution with
a filter like h where all the elements are the same in O(N) time.
d) Show the time difference from the technique discussed in c) by replicating x and h 100 times
to make then 100 times the original length, and time how long the convolution takes with
the regular technique vs the more efficient one.
2
2 Matched filters with cross-correlation
a) Load the “Corcovado.wav” file, and the “clip.wav” file. The “clip.wav” file is a clip of
the “Corcovado.wav” file. Determine the location of the clip in the longer sound file by
computing the cross-correlation between the two signals and looking for the peak. From this
peak, state the time in the song the clip begins. Be sure to remember to convert to float,
and subtract the default padding that is done with correlation by default when converting
to time. The frequency sampling rate is included in the file, this needs to be read also.
Note: These audio files are stereo, meaning there are separate channels for left and right
speaker. For simplicity, just alter the signal to be equal to one of the two channels. Use
scipy’s correlation function for faster results.
3 Fourier series
As we saw in the lectures, periodic waves can be synthesized by summing sine and cosine
waves. In this problem, you will generate an odd square wave y(t) by adding sine waves with
frequencies including odd numbered multiples of a base frequency f. The function can be
formulated as:
y(t) = X
K
k=1
sin(2π(2k − 1)f t)
2k − 1
,
where K = ∞.
a) Create a regularly spaced vector t from 0 to 1 with a length of 1000 and set f to 2.
b) Write a for loop to compute the finite sum of above equation to approximate y for a given
K value.
c) Generate a sine wave using the formula above i.e., K = 1 and plot the result.
d) Generate and plot y(t) with K = 3. Does it look like a square wave?
e) Now, try with 9 and 50 sine waves. Notice the overshoots, does the plot get better?
f) Now try with as much as you want (around 106
) and zoom into the corners. The imperfections
are referred to as the “Gibbs phenomenon.” See https://en.wikipedia.org/wiki/Gibbs_
phenomenon
g) Place all the plots you generated in a plot as subplots, use appropriate labels and titles.
4 Programming a LTI system
Figure 1: System
Implement the depicted system to compute the outputs y1(n) and y2(n) (on n = 0, 1, 2, . . . 1000)
for the input signal x(n) = sin(0.1n) and various user-defined values of β. Note the input is
3
an eternal, periodic signal, defined from −∞ to ∞. You can only use the convolution function
you implemented above, in programming question 1. Visualize some output functions y1 and
y2 for n = 0, 1, 2, . . . 1000, with following values of β = −5, −1, 5. What do you observe about
y1 and how it relates to β and x. How do you explain this behavior? How is y2 related to y1
and x?
4

More products