Lab 3
Lab 3
DATE OF
: Fall 2023
EXPERIMENT
LAB NUMBER : 3
NAME : _______________________________
ROLL NO : ___________________
COMMUNICATION SYSTEMS LAB (308202)
Instructions:
1. You are required to complete and submit ALL the tasks given at the end of each tutorial during
your lab timings strictly.
2. At the end of the lab manual, you will find some experiments which are required to be done as
home assignment and submitted before the next lab.
3. Please show your complete work, through Simulink models and results for both lab performance
(submitted during lab timings) and lab report (report submitted as home assignment).
4. Save your models after performing each step to avoid loss of your work due to any reason.
Objective:
In this lab, you will learn to conduct simulation in Simulink/MATLAB after obtaining:
a. Fourier series of periodic signals.
b. Frequency transfer function of a linear system.
3.1 Periodic Signals and Fourier Series
A periodic function is a function that repeats itself exactly after some given period, or cycle. We represent
the definition of a periodic function mathematically as:
𝑓(𝑡) = 𝑓(𝑡 + 𝑇0 ), (3.1)
where 𝑇0 > 0 represents the period. Any function that satisfies equation (3.1) is a periodic signal. Now,
any periodic function 𝑓(𝑡) with an arbitrary time period 𝑇0 can be represented by a linear combination of
harmonic sinusoids, as follows:
∞
𝑎0
𝑓(𝑡) = + ∑(𝑎𝑛 cos(𝑛𝜔0 𝑡) + 𝑏𝑛 sin(𝑛𝜔0 𝑡)), (3.2)
2
𝑛=1
2𝜋
where 𝜔0 = is the fundamental frequency in rad/seconds. The 𝑎𝑛 and 𝑏𝑛 – Fourier coefficients specify
𝑇0
that “how much” of the sinusoids cos(𝑛𝜔0 𝑡) and sin(𝑛𝜔0 𝑡) are present in 𝑓(𝑡). Equation (3.2) also shows
1
that any combination of sinusoids of frequencies 0, 𝑓0 , 2𝑓0 , … , 𝑛𝑓0 is a periodic signal of period 𝑇0 = 𝑓0
regardless of the values of amplitudes 𝑎𝑛 and 𝑏𝑛 of these sinusoids. By changing the values of 𝑎𝑛 and 𝑏𝑛
in equation (3.2), we can construct a variety of periodic signals, all with same period 𝑇0 . These three
coefficients are computed as:
1
𝑎0 = ∫ 𝑓(𝑡) 𝑑𝑡, (3.3a)
𝑇0
𝑇0
2
𝑎𝑛 = ∫ 𝑓(𝑡) cos(𝑛𝜔0 𝑡) 𝑑𝑡, (3.3b)
𝑇0
𝑇0
2
𝑏𝑛 = ∫ 𝑓(𝑡) sin(𝑛𝜔0 𝑡) 𝑑𝑡. (3.3c)
𝑇0
𝑇0
Clearly, the magnitude and the phase of the output complex sinusoid 𝑦(𝑡) are influenced by |𝐻(𝜔0 )| and
∠𝐻(𝜔0 ), respectively. The general function 𝐻(𝜔), which is the Fourier transform of the system impulse
response, is called the frequency transfer function. The concept will be further explained through tutorial
#2 (Section 3.4).
3.3 Tutorial #1: Designing a Fourier-Series System in Simulink
Consider the following square wave signal:
0 𝜋
1 1
𝑏𝑛 = ∫ 𝑓(𝑡) sin(𝑛𝑡) 𝑑𝑡 + ∫ 𝑓(𝑡) sin(𝑛𝑡) 𝑑𝑡,
𝜋 𝜋
−𝜋 0
0 𝜋
1 1 1
= ∫ 1 sin(𝑛𝑡) 𝑑𝑡 + ∫ 0 sin(𝑛𝑡) 𝑑𝑡 = − (1 − cos(𝑛𝜋)). (3.6c)
𝜋 𝜋 𝑛𝜋
−𝜋 0
Thus,
0, 𝑛 even
𝑏𝑛 = { 2 (3.7)
− , 𝑛 odd
𝑛𝜋
From equations (3.2), (3.6) - (3.7), the Fourier series of the signal shown in Figure 3.1 is given as:
1 2 1 1 1
𝑓(𝑡) = − [sin 𝑡 + sin(3𝑡) + sin(5𝑡) + sin(7𝑡) + ⋯ ], (3.8)
2 𝜋 3 5 7
2𝜋
where 𝜔0 = = 1.
𝑇0
The objective of this tutorial is to check, in Simulink, whether the right-hand side of equation (3.8)
converges to 𝑓(𝑡). Since the right-hand side of (3.8) is the sum of infinite number of scaled sine waveforms
of different frequencies, it is impossible to generate it exactly in Simulink. Thus, a partial-sum
approximation will be performed.
i. Design a Simulink model as shown in Figure 3.2.
Bias: 0,
Sample time: 0.01.
iv. Run the simulation for 20 seconds. Make sure that Layout of the Scope block is properly set to
display all four signals separately.
v. After the simulation completes, double click on the Scope icon to view the waveform.
vi. Document your observations on the Fourier series approximation of the periodic square wave
as the number of sinusoids increases in the sum. Assess both the shape and the ripples in the
approximated waveform.
At the end of this tutorial, you should be able to implement a Simulink model for partial-sum Fourier Series
of a periodic signal and analyze the results.
Task #1
i. Consider a square wave as shown in Figure 3.3.
ii. Set 𝑇0 to the last two digits of your student ID/registration number. For example, if your student
ID is 18040190, then 𝑇0 = 90. Calculate the subsequent frequency 𝜔0 .
iii. Find out Fourier series of the subsequent signal and implement a partial-sum Fourier Series model
in Simulink using equation set (3.3). The derivation of Fourier series shall be part of your lab
performance.
Figure 3.3 A square wave periodic signal for the task in Section 3.4.
iv. Record the remaining work (Simulink model, Scope’s display, Sine Wave blocks settings etc.).
3.4 Tutorial #2: Testing of Frequency Transfer Function in Simulink
Consider an RC low-pass filter shown in Figure 3.4.
With 𝑓(𝑡) and 𝑦(𝑡) defining the input and output voltages, respectively, of the RC circuit shown, their
relationship can be defined through the following differential equation:
𝑑 𝑦(𝑡)
𝑅𝐶 + 𝑦(𝑡) = 𝑓(𝑡). (3.9)
𝑑𝑡
Plugging 𝑓(𝑡) = exp(𝑗𝜔0 𝑡), and 𝑦(𝑡) = 𝐻(𝜔0 ) exp(𝑗𝜔0 𝑡) in equation (3.9), yields:
1 1
𝐻(𝜔0 ) = = | | ∠ − tan−1(𝜔0 𝑅𝐶), (3.10)
1 + 𝑗𝜔0 𝑅𝐶 √1 + (𝜔 0 𝑅𝐶)
2
Figure 3.5 Initial Simulink design for RC low pass filter of Figure 3.4.
iii. Set the Frequency: 10 rad/s in the Sine Wave block and run the simulation for 2 seconds and
display the result on the Scope.
iv. Measure the output signal frequency and compare it with the input frequency. Also note the
difference in their amplitudes.
v. Now re-set the Frequency: 120 rad/s in the Sine Wave block and after running the simulation for
0.2 seconds, compare the input and output signal.
Task #2
Following the steps given in above tutorial, make necessary amendments to develop an RL circuit. Assume
R = 500 Ω and L = 3 H. Take measurement across both R and L at two different (high and low) frequencies.
What type of filter is this?
3.5 Experiments:
i. Consider the Simulink design model developed in Tutorial #2. Keep the same values for resistor
and capacitor.
a. For each of the frequencies 𝜔 given in the first column of Table 3.1, calculate |𝐻(𝜔)| by
using equation (3.10) and fill in the second column. You may need to change the simulation
run time for every frequency to have a proper display on Scope.
b. Measure the output signal amplitude from the model of the RC low-pass filter in Simulink
and complete the third column of the Table 3.1. Is the measured value different than the
calculated value? Why?
ii. To the simulink model of experiment (i), give the periodic input signal generated in tutorial #1
(partial-sum Fourier Series) of this lab. Is the output signal peridoic? Why?
Input Observed |𝑯(𝝎)| from Scope
Calculated |𝑯(𝝎)| from equation
frequency 𝝎 𝑽𝒐𝒖𝒕
(3.10) |𝑯(𝝎)| =
[rad/s] 𝑽𝒊𝒏
0
5
10
20
40
80
120