Lab 4
Lab 4
This lab assignment is on the Fourier series representation of continuous-time signals. You
will be implementing a function for the analysis equation and observe the effects of operations
in time on the Fourier series coefficients. Then, you will be working with a linear time-invariant
system to understand the effects of this system on the Fourier series coefficients of the input.
Please work on this assignment before coming to the laboratory. At the end of the laboratory
session, you must show your completed work for all parts. After the lab session, you will have
one week to format your completed work as a report and submit it on Moodle. Some parts will
be performed by hand, and others will be done using MATLAB. Please address all the questions
asked in the assignment and include all your codes as text and derivations for all parts. Before
the submission deadline, make sure to upload your work as a readable, well-formatted single
PDF file. Note that the MATLAB codes will be tested on MATLAB R2023a. Ensure that
your code does not raise an error or a warning in earlier versions. Do not forget to add proper
captions, axis labels, and titles for any plots you provide.
Part 1
In the lectures, you have learned that a continuous-time periodic signal can be expressed as a
summation of harmonically related frequency components as follows:
∞
X
x(t) = ak ejk(2π/To )t (synthesis formula) (1)
k=−∞
where ak s are the weight of the each kth harmonic component, ejk(2π/To )t , contained in the
periodic signal x(t), or the Fourier series coefficients. Here, 2π
To
is equal to the periodic signal’s
fundamental frequency ωo .
Using the analysis formula, you may express the Fourier series coefficients as follows:
Z
1
ak = x(t)e−jk(2π/To )t dt (analysis formula) (2)
To To
1
period of your signal (To ) using direct proportionality. Once you determine the boundaries of
your summation, you may simply replace To with N , and the continuous time variable t with
the sample index n in your calculations. In the end, your function should look like:
• fsCoeffs: An array that contains the Fourier series coefficients of your signal from -k
to k
• x: One complete period of the sampled continuous-time signal
• k: The number of two-sided Fourier series coefficients that you will estimate
(i.e., you will find the coefficients a−k , a−k+1 , . . . , a0 , . . . , ak−1 , ak )
b) Then, using your function FSAnalysis, estimate the Fourier series coefficients of the
signals x1 (t) and x2 (t) for Ts = 0.001 s and k = 30. For each signal, plot the real and imaginary
part of the estimated Fourier series coefficients in a subplot using the stem command. Then,
compare your calculations in part a) with the values in your plots. Comment on your results.
c) Show that the Parseval’s Relation holds computationally, using the output of your func-
tion FSAnalysis and the signal x1 (t) on MATLAB.
Note: As your signal is the sampled version of your continuous-time signal, do not forget to
multiply the summation you found for the time domain with the sampling period Ts .
Part 2
In this part, you will be observing the effects of various operations in the time domain on the
Fourier series coefficients. For this purpose, let us define the signal x3 (t) as follows:
2
Then, express the Fourier series coefficients for the following signals defined in terms of
x3 (t). Also, obtain the Fourier series coefficients of these signals using the FSAnalysis func-
tion and plot the real and imaginary parts of the coefficients on the same figure as subplots
using the stem command. Compare your plots for the coefficients of x3 (t) and zi (t) signals,
where i = 1, 2, 3, 4, 5. What changes do you observe in the Fourier series coefficients for each
time-domain operation? Comment on your results for each case.
Note 1: As you are working with sampled continuous-time signals, if you would like to imple-
ment an impulse response, do not forget to divide its amplitude by Ts .
Note 2: For part d), set the limits of the y axis as ylim = ([-1, 1.5]) in both the real and
imaginary part plots to observe the effects more clearly.
a) z1 (t) = x3 (−t)
dx3 (t)
b) z2 (t) = dt
c) z3 (t) = x3 (t + 2)
d) z4 (t) = Ev{x3 (t)}
e) z5 (t) = x23 (t)
Part 3
3.1 A Second-Order System
The input-output relationship of the system depicted in Figure 1 can be described by the
following second-order differential equation:
d2 y(t) dy(t)
M + c + κy(t) = f (t) (3)
dt2 dt
where y(t) is the displacement with respect to the initial position of the center of mass, dy(t)
dt
is
d2 y(t)
the velocity, dt2 is the acceleration of the mass in this system, and f (t) is the function that
3
defines the exerted force on the mass with respect to time. The coefficients M , c, and κ are
the effective mass, damping coefficient, and stiffness of the spring, respectively.
Abstraction of the physical system is provided as a block diagram in Figure 2. Using the
properties of continuous-time Fourier series coefficients, express both sides of Eqn.(3) in terms
of their Fourier series coefficients, and then relate the Fourier series coefficients of y(t), denoted
by bk , and those of f (t), named ak . Also, state this relation, in terms of the system’s frequency
response H(jω). Then, express H(jkωo ) in terms of M , c, and κ.
Final Remarks
Submit the results of your own work in the form of a well-documented lab report on Moodle.
Borrowing full or partial code or other material from your peers or elsewhere is not allowed
and will be penalized.
Throughout this assignment, you are not allowed to use symbolic operations in MATLAB.
The axes of all plots should be scaled and labeled. To modify the styles of the plots, add labels,
and scale the plots, use only MATLAB commands; do not use the GUI of the figure windows.
4
When your program is executed, the figures must appear exactly the same as you provide in
your solution. You need to write your MATLAB codes not only correctly but efficiently as well.
Please include all evidence (plots, screenshots, MATLAB codes, MATLAB command win-
dow print-outs, etc.) as needed in your report. Append your MATLAB code at the end of
your assignment as text, not as an image, and do not upload it separately. You can use the
“Publish” menu of MATLAB to generate a PDF file from your codes and their outputs and
append it to the end of your report. If you do this, please also indicate the part that the code
corresponds to with a label. Typing your report instead of handwriting some parts will be
better. If you decide to write some parts by hand, please use plain white paper. Please do not
upload any photos/images of your report. Your complete report should be uploaded on Moodle
as a single good-quality pdf file by the given deadline. Please try to upload several hours
before the deadline to avoid last-minute problems that may cause you to miss the deadline.
Please do not submit files by e-mail or on memory stick/CD or as hard copies.
Please name the PDF file you submit on Moodle as follows, using only lower-case English
characters for your first name, middle name (if any), and last name. Please use your full name
as it appears on the Bilkent system.