CPE223-Signals and Systems Lab Manual
CPE223-Signals and Systems Lab Manual
Supervised By
Dr. Khurram Ali
Program: Batch:
Semester
Revision History
3 Modifications Bajwa
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual iii
Preface
This course allows the students to analyze in depth the signals and systems in time, frequency and z- domains
respectively. Thorough understanding of signals and systems in time domain further helps the students to
study their applications in frequency domain quite comprehensively. Based on our experience, working in
frequency domain is always a fun and more often simplifies many engineering problems and disseminates a
more compact overview of the problem. The rationale behind this course is to make the student able to think
in various dimensions especially in frequency domain. It is expected that student should acquire familiarity
with mathematical representation of signals and systems.
After the completion of this course, following key educational aims are expected to be achieved and the
student should be able to:
• Understand the representation of continuous and discrete time signals and systems in time domain.
• Analyze continuous and discrete – time signals and systems in time domain.
• Study and analyze frequency domain versions of different systems along with their Characteristics.
• Determine Fourier series/and Fourier Transforms representation of Periodic and A-periodic Signals.
• Grasp concepts of Fourier Transform and Discrete time Fourier Transform, and understand their
properties.
• Grasp concepts of Laplace transform, analysis of properties and characterization of LTI systems.
• Grasp concepts of z transform, analysis of properties and characterization of LTI.
• Acquire enough understanding to build a comprehensive foundation for later higher level courses such
as communication systems, control systems and digital signal processing.
• Implement these concepts on MATLAB.
• Utilize mathematical skills for analyzing and solving complex systems.
• Use his/her software skills of MATLAB in processing signals through systems for various engineering
applications.
• Apply the knowledge of this course towards learning of higher level modules such as Analog and Digital
Communication Systems, Modern Control Systems and Digital Signal Processing.
This is a basic course that is intended to provide the fundamentals of signals, systems and transforms to the
electrical engineering students. The student should acquire familiarity with mathematical representation of
signals and systems. S/he should be able to think in frequency domain. The course is aimed to build a
comprehensive foundation for later higher level courses in communication system, control systems and digital
signal processing. Both discrete-time and continuous-time signals, systems and transforms are covered in the
course.
Reference Books
1. Linear Systems by and Signals by B.P Lathi, Latest Edition, Oxford Press.
2. Signals and Systems by Simon Haykin & Bary Van Veen, Latest Edition, John Wiley & Sons.
3. Signals and Systems by Alan V Oppenheim & Willisky, Latest Edition, Prentice Hall.
Learning Outcomes
1. Understand the representation of continuous and discrete time signals and systems in timedomain.
2. Analyse continuous and discrete – time signals and systems in time domain.
3. Study and analyse frequency domain versions of different systems along with their Characteristics.
4. Determine Fourier series/and Fourier Transforms representation of Periodic and A-periodic Signals.
5. Grasp concepts of Fourier Transform and Discrete time Fourier Transform, and understand their
properties.
6. Grasp concepts of Laplace transform, analysis of properties and characterization of LTI systems.
7. Grasp concepts of z transform, analysis of properties and characterization of LTI.
8. Implement the course concepts on MATLAB.
Software Resources
✓ MATLAB Latest Version.
List of Equipment
✓ Personal Computers
The final marks for lab would comprise of Lab Assessment (25%), Lab S1 (10%), Lab S2 (15 %) and Lab Terminal
(50%).
S-I 0.5*(S-I Exam result) + 0.5* (average of lab evaluation of Lab 1-4)
S-II 0.5*(S-II Exam result) + 0.5*[ (average of lab evaluation of Lab 5-8) * 1.5]
Terminal 0.25*[(average of lab evaluation of Lab 9-14) *5] + 0.10*[(average of lab evaluation of Lab 5-8) *5] +
0.15*[(average of lab evaluation of Lab 1-4) *5]
Lab Assignment Marks:
• Lab Assignment 1 marks = Lab report marks from experiment 1-3.
• Lab Assignment 2 marks = Lab report marks from experiment 4-6.
• Lab Assignment 3 marks = Lab report marks from experiment 7-9.
• Lab Assignment 4 marks = Lab report marks from experiment 10-14.
The minimum pass marks for both lab and theory shall be 50%. Students obtaining less than 50% marks (in either
theory or lab, or both) shall be deemed to have failed in the course. The final marks would be computed with 75%
weight to theory and 25% to lab final marks.
Lab Instructions
✓ This lab activity comprises of three parts: Pre-lab, Lab Tasks, Critical Analysis and Conclusion and Viva
session.
✓ The students should perform and demonstrate each lab task separately for step-wise evaluation.
✓ Only those tasks that are completed during the allocated lab time will be credited to the students.
Students are however encouraged to practice on their own in spare time for enhancing theirskills.
✓ Lab objectives
✓ MATLAB codes
✓ Results (graphs/tables) duly commented and discussed ✓ Conclusion
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual vii
List of Experiments
Experiment 1: To Identify the Continuous and Discrete Time Signals Using MATLAB
Experiment 2: To Describe the Periodic and Aperiodic Continuous and Discrete Time Signals using
Elementary Signals in MATLAB
Experiment 3: To Explain the Properties of Different Signal Types Using Signal Operations in
MATLAB
Experiment 4: To Show the Response of Different System Classifications Using I/O Relationship in
MATLAB
Experiment 5: To Explain the Properties of the System Using I/O Relationship in MATLAB
Experiment 6: To Sketch the Response of Linear Time Invariant Systems by Performing Convolution
Using MATLAB
Experiment 7: To Sketch the Line Spectrum of Periodic Signals Using Properties of Fourier Series
Coefficients in MATLAB
Experiment 8: To Reproduce the Continuous Time Fourier Transform (CTFT) Using MATLAB
Functions
Experiment 9: To Reproduce the Discrete Time Fourier Transform (DTFT) Using MATLAB Functions
Experiment 10: To Show the Response of Continuous Time Signals Using Laplace Transform in
MATLAB
Experiment 11: To Reproduce the Properties of Laplace Transform Using MATLAB Functions
Experiment 12: To Measure the Response of Discrete Time Signals Using z-Transform in MATLAB
Experiment 13: To Reproduce the Properties of z-Transform Using MATLAB Functions
Experiment 14: To Construct the Digital Filters Using Direct Form I & II in MATLAB
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual viii
Experiment Relevant to Learning Outcome
To measure and display the response of various signals and systems using
Experiment 1-14
MATLAB design and simulation tool. (PLO5-P4)
To explain and write effective lab reports of experiments performed during the
Experiment 1-14
laboratory sessions. (PLO10-A3)
CLO-PLO Mapping
PLO
Psychomotor
PLO10
PLO11
PLO12
Cognitive
Affective
PLO1
PLO2
PLO3
PLO4
PLO5
PLO6
PLO7
PLO8
PLO9
Level
Level
level
CLOs
CLO1 X C3
CLO2 X C3
CLO3 X C4
CLO4 X P4
CLO5 X A3
Lab 11
Lab 12
Lab 13
Lab 14
LABs
Lab 1
Lab 2
Lab 3
Lab 4
Lab 5
Lab 6
Lab 7
Lab 8
Lab 9
CLOs
CLO4 P1 P1 P2 P2 P2 P3 P3 P3 P3 P4 P4 P4 P4 P4
CLO5 A1 A1 A1 A2 A2 A2 A2 A2 A2 A3 A3 A3 A3 A3
Contents
Revision History .................................................................................................................................................... iii
Preface.................................................................................................................................................................. iv
Books ..................................................................................................................................................................... v
Text Books ......................................................................................................................................................... v
Reference Books ................................................................................................................................................ v
Reference Books for Manual ............................................................................................................................. v
Learning Outcomes ............................................................................................................................................... v
Software Resources ............................................................................................................................................... v
List of Equipment .................................................................................................................................................. v
Grading Policy....................................................................................................................................................... vi
Lab Instructions .................................................................................................................................................... vi
Lab Report Instructions ........................................................................................................................................ vi
Safety Instructions................................................................................................................................................vii
List of Experiments ..............................................................................................................................................viii
Experiment Relevant to Learning Outcome ..........................................................................................................ix
CLO-PLO Mapping .................................................................................................................................................ix
Lab CLOs – Lab Experiment Mapping ....................................................................................................................ix
Table of Contents .................................................................................................................................................. x
LAB # 1: To Identify the Continuous and Discrete Time Signals Using MATLAB ................................................. 15
Objectives ............................................................................................................................................................ 15
Pre Lab ................................................................................................................................................................. 15
Part I –Introduction to MATLAB .......................................................................................................................... 15
What is MATLAB? ............................................................................................................................................ 15
M-Files ............................................................................................................................................................. 15
Scripts .............................................................................................................................................................. 15
Lab Tasks ............................................................................................................................................................. 15
Functions ......................................................................................................................................................... 16
Useful Commands............................................................................................................................................ 16
Special Forms of Matrices ............................................................................................................................... 17
Symbolic Variables ........................................................................................................................................... 18
Part II- Plotting Signals in MATLAB ...................................................................................................................... 18
Plotting in Two Dimensions ............................................................................................................................. 18
Plotting Several Function in One Figure .......................................................................................................... 20
Formatting a Figure ......................................................................................................................................... 21
Plotting in Different Figures ............................................................................................................................ 22
Plotting the Continuous Time and Discrete Time Functions ........................................................................... 23
LAB # 2: To Describe the Periodic and Aperiodic Continuous and Discrete Time Signals Using Elementary
Signals in MATLAB ............................................................................................................................................... 28
Objectives ............................................................................................................................................................ 28
Pre Lab ................................................................................................................................................................. 28
Part I- Characterization of Signal by Variable Type ............................................................................................. 28
Continuous Time Signals.................................................................................................................................. 28
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual x
Discrete Time Signals ....................................................................................................................................... 28
Digital Signals ................................................................................................................................................... 28
Part II - Basic Continuous Time Signals ............................................................................................................... 28
Sinusoidal Signal .............................................................................................................................................. 28
Complex Exponential Signals ........................................................................................................................... 29
Exponential Signals .......................................................................................................................................... 29
Unit Step Function ........................................................................................................................................... 29
Unit Impulse or Dirac Delta Function .............................................................................................................. 29
Part III – Basic Discrete Time Signals ................................................................................................................... 30
Unit Impulse Sequence .................................................................................................................................... 30
Unit Step Sequence ......................................................................................................................................... 30
Real Exponential Sequence ............................................................................................................................. 30
Sinusoidal Sequence ........................................................................................................................................ 30
Pre Lab Tasks ....................................................................................................................................................... 31
Lab Tasks ............................................................................................................................................................. 31
LAB# 3: To Explain the Properties of Different Signal Types Using Signal Operations in MATLAB .................... 42
Objectives ............................................................................................................................................................ 42
Pre Lab ................................................................................................................................................................. 42
Part I-Properties of Continuous Time Signals ..................................................................................................... 42
Continuous Time Periodic Signals ................................................................................................................... 42
Sum of Continuous Time Periodic Signals ....................................................................................................... 42
Discrete Time Periodic Signals ......................................................................................................................... 43
Continuous Time and Discrete Time Casual Signal ......................................................................................... 43
Sum of Periodic Discrete-Time Periodic Signals .............................................................................................. 43
Even and Odd Signal / Sequence ..................................................................................................................... 43
Energy and Power Signals/ Sequence ............................................................................................................. 43
Part II- Signal Transformations ............................................................................................................................ 44
Transformations of the time Variable for Continuous-Time Signals ............................................................... 44
Pre Lab Tasks ....................................................................................................................................................... 45
Lab Tasks ............................................................................................................................................................. 45
LAB # 4: To Show the Response of Different System Classifications Using I/O Relationship in MATLAB .......... 54
Objectives ............................................................................................................................................................ 54
Pre Lab ................................................................................................................................................................. 54
Introduction to Systems .................................................................................................................................. 54
System Classification ....................................................................................................................................... 54
Pre Lab Tasks ....................................................................................................................................................... 55
Lab Tasks ............................................................................................................................................................. 55
LAB # 5: To Explain the Properties of the System Using I/O Relationship in MATLAB ....................................... 60
Objectives ............................................................................................................................................................ 60
Pre-Lab ................................................................................................................................................................ 60
Properties of System ....................................................................................................................................... 60
Pre lab Tasks ........................................................................................................................................................ 61
Lab Tasks ............................................................................................................................................................. 61
LAB # 6: To Sketch the Response of Linear Time Invariant Systems by Performing Convolution Using MATLAB
............................................................................................................................................................................. 69
Objedfctives......................................................................................................................................................... 69
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual xii
Objectives .......................................................................................................................................................... 113
Pre Lab ............................................................................................................................................................... 113
Z-Transform and Inverse Z-Transform........................................................................................................... 113
Commands ztrans and iztrans ....................................................................................................................... 114
Region of Convergence.................................................................................................................................. 114
Z- Transform Pairs.......................................................................................................................................... 114
Inverse Z-Transform through Partial Fraction ............................................................................................... 115
Pre Lab Task....................................................................................................................................................... 115
Lab Tasks ........................................................................................................................................................... 116
LAB # 13: To Reproduce the Properties of Z-Transform Using MATLAB Functions .......................................... 119
Objectives .......................................................................................................................................................... 119
Pre Lab ............................................................................................................................................................... 119
Z-Transform Properties and Theorems ......................................................................................................... 119
Pre Lab Tasks ..................................................................................................................................................... 126
Lab Tasks ........................................................................................................................................................... 126
LAB # 14: To Construct the Digital Filters Using Direct Form I & II in MATLAB ................................................ 128
Objectives .......................................................................................................................................................... 128
Pre Lab ............................................................................................................................................................... 128
IIR Filter Structures ........................................................................................................................................ 128
MATLAB Implementation .............................................................................................................................. 129
FIR Filter Structures ....................................................................................................................................... 130
MATLAB Implementation .............................................................................................................................. 131
Lab Tasks ........................................................................................................................................................... 132
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual xiii
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual xiv
LAB # 1: To Identify the Continuous and Discrete Time Signals Using
MATLAB
Objectives
After completing this lab, the student will be able to:
Pre Lab
M-Files
In order to write many commands that are executed all together, the program must be written in a text editor.
In this editor, one can type all the needed commands to form a program, save the program, and execute it
any time he or she wants. The text files are called M-files due to their suffix *.m.
There are two categories of M-files: the Scripts and the Functions.
Scripts
Scripts are the M-files with MATLAB commands. Their name must have a .m suffix. Scripts are suitable for
solving the problems that require many commands. The advantage of the scripts is that they are implemented
very easily.
Lab Tasks
Lab Task
Write a script file and execute.
t=-5:0.1:5;
f=t.*cos(2*pi*t);
plot(t,f)
Lab Task
Write a function file and execute. Function should accepts as input two matrices and returns their sum and
product.
function [sm,pro]=oper(A,B)
sm=A+B;
pro=A*B;
end
Useful Commands
Here we will learn and practice useful (when working with vectors and matrices) commands. As already
discussed, the command sum returns the sum of the elements of a vector. The command cumsum returns a
vector whose elements are the cumulative sum of the previous elements, the command prod is the product
of the vector elements, while the command diff returns a vector in which each element is given by its
Commands Results/Comments
a = [4 2 7 0 6] a = 4 2 7 0 6
%Definition of vector .
s = sum(a) s = 19
%Sum the elements of . c
c = cumsum(a) = 4 6 13 13 19
%Cumulative sum. The result is obtained as
p = prod(a) [4,4+2,4+2+7, 4+2+7+0, 4+2+7+0+6]
p = 0
d = diff(a) %Product of all elements.
d = -2 5 -7 6
[m,i] = max(a) % Difference between two consecutive elements i.e.,
d(1)=a(2)-a(1) ,etc.
m = 7
i = 4
%The largest value is assigned to the variable m, and its
index is assigned to variable i.
[m,i] = min(a) m = 0
i = 3
%The smallest value is assigned to the variable m, and its
index is assigned to variable i.
max(a) ans = 7
%If no output variable is specified, only the largest value
is returned.
median(a) ans = 4
%Median value of the vector.
sort(a) ans = 0 2 4 6 7
%Sorting in ascending order.
sort(a,’descend’) ans = 7 6 4 2 0
%Sorting in descending order.
eye(3) Ans = 1 0 0
0 1 0
0 0 1
%The identity matrix 1 of size 3x3.
A = 8 1 6
A = magic(3) 3 5 7
4 9 2
%Magic matrix
Symbolic Variables
In MATLAB, a variable type is the symbolic variable (or object). A symbolic variable is defined by the command
sym and syms. The use of symbolic variables allows the computation of limits, integrals, derivativesetc.
x = -2 -1 0 1 2
ans = 5
y= 4 1 0 1 4
ans = 5
Lab Task
Plot the in the same figure.
Formatting a Figure
The command grid on adds lines to the graph, while the command grid off removes the grid lines. Simply
typing grid is switch between the two modes. Text besides the x-axis and y-axis can be added using the
commands xlabel and ylabel, respectively. A graph title is inserted by the Command title.
x = linspace(0,2*pi,150);
plot(x,cos(x),'r*',x,sin(x),'k')
xlabel('Time Axis')
ylabel('Amplitude')
title('Graph of cos(x) & sin(x)')
legend('cos','sine')
Lab Task
Plot the functions that were plotted in last lab task in the following two ways.
Lab Task
Plot the discrete function𝑓[𝑛] = 𝑛2, 𝑤ℎ𝑒𝑟𝑒 − 2 ≤ 𝑛 ≤ 2.
Sidra Saleem 24 24
CPE223 Signals and Systems Lab Manual
Now we will discuss the way of defining and plotting functions with more than one part.
Lab Task
Plot the following function
t1=-2:.1:2;
t2=2.1:.1:4.9;
t3=5:.1:8;
f1=ones(size(t1));
f2=zeros(size(t2));
f3=t3.*sin(4*pi*t3);
t=[t1 t2 t3];
f=[f1 f2 f3];
plot(t,f)
title('Multi-part function f(t)')
xlabel( 'time')
ylabel( 'Amplitude')
Objectives
After completing this lab, the student will be able to:
✓ Describe and show the basic Continuous and Discrete time signals (sinusoidal and complex
exponential) by using elementary signals (unit step and unit impulse).
Pre Lab
Digital Signals
Digital signals are the signals that both independent and dependent variables take values from a discrete set.
In the following example, the signal 𝑦[𝑛] = cos[𝑛] is again plotted, but we use the command round to limit
the set of values that 𝑦[𝑛] can take, That is, 𝑦[𝑛] can be .
Sinusoidal Signal
The first basic category presented is that of sinusoidal signal. This type of signal is of the form
Where
Exponential Signals
Exponential signals are signals of the form
.
If 𝑏 > 0, 𝑥(𝑡) is an increasing function while
if 𝑏 < 0, 𝑥(𝑡) is a decreasing function.
At the signal takes the value
The MATLAB command that generates the unit step function is the command heaviside(t).
For special reasons, 𝛿(𝑡) can be loosely defined as a function that is infinite at t=0 and zero elsewhere. This is
the way that 𝛿(𝑡) is implemented from the MATLAB programmers. The mathematical expression is
∞ 𝑡 =0
𝛿(𝑡) = {
0 𝑡 ≠0
An alternative definition for the Dirac function that is usually applicable when dealing with discrete-time signal
is given now. In this case, we refer to 𝛿(𝑡) as the Delta or the Kronecher function. The mathematical definition
of delta function is
1. The definition of the time. For the discrete time signals, time is defined by the step 1.
2. The graph of the discrete time signals is obtained by the stem command. Stem is similar to plot but is
suitable for discrete time signals.
Sinusoidal Sequence
The sinusoidal sequence is defined by the expression of the form
Where
𝐴 = 𝐴𝑚𝑝𝑙𝑖𝑡𝑢𝑑𝑒
𝜑 = 𝑝ℎ𝑎𝑠𝑒
𝜔 = 𝑓𝑟𝑒𝑞𝑢𝑒𝑛𝑐𝑦
4. Rectangular Pulse Function: The rectangular pulse function is rectangular pulse with unit
amplitude and duration T. it is defined in terms of the unit step function as
Lab Tasks
Lab Task
Plot the continuous time signal .
Your plotted signal should look like as shown in the figure
0.6
0.4
a, 0.2
-0
-
ci.. 0
E
<( -0.2
-0.4
-0.6
-0.8
-8 -6 -4 -2 0 2 4 6 8 10
Time
Lab Task
Plot the digital signal
Lab Task
Plot the following two signals together in the same plot.
, and
Lab Task
Plot the unit impulse function.
The student performance for the assigned task during the lab session was:
The student completed assigned tasks without any help from
Excellent 4
the instructor and showed the results appropriately.
The student completed assigned tasks with minimal help from the
Good 3
instructor and showed the results appropriately.
The student could not complete all assigned tasks and showed
Average 2
partial results.
Worst The student did not complete assigned tasks. 1
Objectives
After completing this lab, the student will be able to:
✓ Display the periodic signals, casual signals, energy and power signals, even and odd signals,
deterministic and stochastic signals using MATLAB.
✓ Show the results obtained after performing the composite operations on signals (time reversal, time
scaling and time shifting) in MATLAB.
Pre Lab
If T is the smallest positive value of T for which above equation is satisfied, then T is called the fundamental
period of the signal. Moreover, if k Z another expression that denotes the periodicity of a signal is
For example, a sinusoidal signal 𝑥(𝑡) = 𝐴𝑐𝑜𝑠(𝑤𝑡 + 𝜃) is periodic with fundamental period 𝑇 = 2𝜋 but
𝜔
𝑇 = 4𝜋 , 𝑇 = 6𝜋, 𝑇 = 8𝜋, etc. are also periods of the signal 𝑥(𝑡).
𝜔 𝜔 𝜔
Suppose that x(t) is indeed periodic with period T. Then, the following relationship holds:
𝑥(𝑡) = 𝑥(𝑡 + 𝑇) = 𝑥1(𝑡 + 𝑇) + 𝑥2(𝑡 + 𝑇)
Equation is valid if
A discrete-time signal x[n] is periodic if there are integer positive numbers such that
A signal 𝑥(𝑡) is odd (or has odd symmetry or is an odd function of t) if 𝑥(−𝑡) = −𝑥(𝑡), −∞ < 𝑡 < ∞ and the
same hold for the sequence 𝑥[𝑛].
Where |𝑥(𝑡)| is the absolute value of 𝑥(𝑡). A signal is an energy signal if its energy is definite,
i.e.,0 ≤ 𝐸𝑥 < ∞ .
A signal 𝑥[𝑛] is called a power signal if 0 ≤ 𝑃𝑥 < ∞ In order to calculate the energy or the power of a signal,
recall that the command 𝑙𝑖𝑚𝑖𝑡(𝐹, 𝑥, 𝑎) computes the limit of the function F when the symbolic variable x
tends to a.
The operation of time reversal is actually an alternation of the signal values between negative and positive
time. Assume that x is the vector that denotes the signal in time t. The MATLAB statement that plots
the reflected version of x(t) is plot (-t,x).
A signal is called a power signal if 0 ≤ 𝑃𝑥 < ∞ In order to calculate the energy or the power of a signal,
recall that the command 𝑙𝑖𝑚𝑖𝑡(𝐹, 𝑥, 𝑎) computes the limit of the function F when the symbolic variable x
tends to a.
Time Scaling
The second operation discussed is timing scaling. A signal is compressed version of 𝑥(𝑡) if 𝑥1(𝑡) =
𝑥(𝑎𝑡), 𝑎 > 1. The time compression practically means that the time duration of the signal is reduced by a
factor a. On the other hand, a signal is expanded version of if 𝑥2(𝑡) = 𝑥(𝑎𝑡), 𝑎 < 1. In this case, the
time duration of the signal is increased by a factor 1/a.
In order to plot in MATLAB a time-scaled version of 𝑥(𝑡), namely, a signal of the form 𝑦(𝑡) = 𝑥(𝑎𝑡), the
statement employed is plot . In contrast to what someone would expect the vector of time t must be
multiplied by 1/a and not a.
Lab Tasks
Lab Task
Verify that the signal 𝑥(𝑡) = sin(𝑡) is periodic.
Lab Task
Plot the causal, non-causal and anti-causal signal and sequence.
Lab Task
Find that signal is periodic/ aperiodic.
Lab Task
Decompose the unit step sequence into even and odd parts over the interval
and verify your result by constructing unit step signal from the even and odd parts.
Lab Task
Compute the energy and the power of the signal 𝑥(𝑡) = 2𝑐𝑜𝑠(𝜋𝑡) in one period time.
Lab Task
Compute the energy of the signal 𝑥[𝑛] = cos[𝑛] , −𝑅𝑜𝑙𝑙 𝑁𝑢𝑚𝑏𝑒𝑟 ≤ 𝑛 ≤ 𝑅𝑜𝑙𝑙 𝑁𝑢𝑚𝑏𝑒𝑟
Lab Task
Consider again the continuous-time signal𝑥(𝑡) = 𝑡𝑒−𝑡, −1 ≤ 𝑡 ≤ 3. We will plot the signal 𝑥1 = 𝑥(2𝑡),
which is a time compression of 𝑥(𝑡) by a factor a=2; and the signal 𝑥2 = 𝑥(0.5𝑡), which is a time expansion
of 𝑥(𝑡) by a factor 1/a=2.
The student performance for the assigned task during the lab session was:
The student completed assigned tasks without any help from
Excellent 4
the instructor and showed the results appropriately.
The student completed assigned tasks with minimal help from the
Good 3
instructor and showed the results appropriately.
The student could not complete all assigned tasks and showed
Average 2
partial results.
Worst The student did not complete assigned tasks. 1
✓ Explain the system classification on the basis of number of input signals it accepts and number of
output signals it returns.
✓ Display the output response of these systems.
Pre Lab
Introduction to Systems
The main categories in which system are classified are given and the basic properties of systems are described.
A system is a concept with a very wide meaning used in various expressions of everyday life. From an electrical
engineering perspective, a system is an entity that manipulates one or more signals. A more formal definition
is that a continuous-time or discrete-time system is an entity that transforms an input signal 𝑥(𝑡) or 𝑥[𝑛] into
an output signal 𝑦(𝑡) or 𝑦[𝑛] according to a specified operation. The transformation of 𝑥(𝑡) or 𝑥[𝑛] is denoted
by 𝑦(𝑡) = 𝑆{𝑥(𝑡)} or where S denotes the system. In simple words, one can say that a system responds to an
input signal 𝑥(𝑡) or 𝑥[𝑛] by an output 𝑦(𝑡) or 𝑦[𝑛].
From a signals and systems perspective, a system is considered a black box, which means that it is examined
in terms of its input, output, and properties without the need to know its internal working. An example of a
system is an electrical guitar. Consider the music note played by the guitarist as the input signal. The electrical
guitar, the amplifier, and the sound boxes constitute the system. The output signal is the actual sound that
the audience hears. The output signal is different (louder, i.e., has a higher amplitude and usually a longer
duration) form the input signal. Considering a black box approach, we are interested in the input and the
output signals and not the internal implementation of the system (e.g., the circuit of the amplifier).
System Classification
In this section, system is divided into categories according to some criteria.
1. Suppose that a MISO system S is described by the I/O relationship 𝑦[𝑛] = 𝑥1[𝑛]/(𝑥2[𝑛] + 𝑥3[𝑛]).
Compute and plot the system’s output if the input signals are given by 𝑥1[𝑛] = 𝑢[𝑛], 0 ≤ 𝑛 ≤ 5,
𝑥2[𝑛] = −𝑢[𝑛], 0 ≤ 𝑛 ≤ 5, and 𝑥3[𝑛] = 𝑢[1 − 𝑛], 0 ≤ 𝑛 ≤ 5.
(Note: Make necessary changes to the input signals if you encounter dimension mismatch error)
Lab Tasks
Lab Task
Suppose that a MIMO system is described by the I/O relationship 𝑦1(𝑡) = 𝑥1(𝑡) + 𝑥2(𝑡) and 𝑦2(𝑡) =
𝑥1(𝑡) − 𝑥2(𝑡). Compute and plot the system response to the input signal 𝑥1(𝑡) = 𝑢(𝑡) and 𝑥2(𝑡) =
0.5𝑢(𝑡)
Lab Task
Suppose that a MIMO system is described by the I/O relationship 𝑦1(𝑡) = 𝑥1(𝑡) + 𝑥2(𝑡) and 𝑦1(𝑡) =
𝑥1(𝑡) − 𝑥2(𝑡). Compute and plot the system response to the input signals 𝑥1(𝑡) = 𝑢(𝑡) and 𝑥2(𝑡) =
0.5𝑢(𝑡 − 1).
Lab Task
A MIMO system is described by the I/O relationships and
. Compute and plot the system response to the input signals𝑥 1(𝑡) = 𝑢(𝑡) and 𝑥2(𝑡) = 𝑛2 for
.
The student performance for the assigned task during the lab session was:
The student completed assigned tasks without any help from
Excellent 4
the instructor and showed the results appropriately.
The student completed assigned tasks with minimal help from the
Good 3
instructor and showed the results appropriately.
The student could not complete all assigned tasks and showed
Average 2
partial results.
Worst The student did not complete assigned tasks. 1
✓ Show the properties (causality, linearity, stability and time invariance,) of different systems using
MATLAB.
Pre-Lab
Properties of System
In this section, we introduce the basic system properties. An illustrative example accompanies each property.
Of course, an example does not prove a property. However, the illustrated examples are carefully selected in
order to correspond with the introduced property. The following properties apply to both continuous-time
and discrete-time systems.
In other words, the response of a linear system to an input that is a linear combination of two signals is the
linear combination of the responses of the system to each one of these signals. The linearity property is
generalized for any number of input signals, and this is often referred to as the principle of superposition.
The linearity property is a combination of two other properties the additive property and the homogenous
property. A system S satisfies the additive property if for any input signals𝑥1(𝑡) and 𝑥2(𝑡).
While the homogeneity property implies that for any scalar a and any input signal 𝑥(𝑡),
𝑆{𝑎𝑥(𝑡)} = 𝑎𝑆{𝑥(𝑡)}
From the above equations, we conclude that if a system is time invariant, the amplitude of the output signal
is the same independent of the time instance the input is applied. The difference is a time shift in the output
signal. A non-time – invariant system is called time – varying or time - variant system.
Stability
Stability is a very important system property. The practical meaning of a stable system is that for a small applied
input the system response is also small (does not diverge). A more formal definition is that a system is stable
or bounded- input bounded-output (BIBO) stable if the system response to any bounded-input signal is a
bounded-output signal. The mathematical expression is as follows. Suppose that a positive number 𝑀 < ∞
exists, such that |𝑦(𝑡)| ≤ 𝑁. A non-stable system is called unstable.
Lab Tasks
Lab Task
Using the input signal 𝑥(𝑡) = 𝑢(𝑡) − 𝑢(𝑡 − 1) find out if the system described by the I/O relationship 𝑦(𝑡) =
3𝑥(𝑡) and 𝑦(𝑡) = 𝑥(𝑡 − 1) are static or dynamic.
Lab Task
Let be input signals to the systems described by the I/O relationship
and . Determine if the linearity property holds for these two systems.
Lab Task
Find out if the discrete-time system described by the I/O relationship for the input signal x[n] =
2n is
a) Static or dynamic
b) Causal or non causal
c) Linear or not linear (x2[n] = n/3 )
d) Shift invariant or shift variant
The student performance for the assigned task during the lab session was:
The student completed assigned tasks without any help from
Excellent 4
the instructor and showed the results appropriately.
The student completed assigned tasks with minimal help from the
Good 3
instructor and showed the results appropriately.
The student could not complete all assigned tasks and showed
Average 2
partial results.
Worst The student did not complete assigned tasks. 1
✓ Construct and display the convolution and deconvolution of Continuous and Discrete time signals
using MATLAB.
Pre Lab
Computation of Continuous-Time Convolution
The impulse response of a linear time-invariant system completely specifies the system. More specifically, if
the impulse response of a system is known one can compute the system output for any input signal. We now
present on of most important topics in signals and systems theory.
The response (or output) of a system to any input signal is computed by the convolution of the input
signal with the impulse response of the system.
Suppose that denotes the output of the system, is the input signal, and is the impulse response
of the system. The mathematical expression of the convolution relationship is
Where, the symbol * denotes convolution, and it must not be confused with the multiplication symbol. The
calculation of the convolution between two signals involves the computation of an integral. The complete
form of is
This process is called deconvolution and is implemented in MATLAB using the command deconv. The syntax
is 𝑥 = 𝑑𝑒𝑐𝑜𝑛𝑣(𝑦, ℎ) where x is the input vector, h is impulse response vector, and y is the system response
vector. The deconvoution process is also useful for determining the impulse response of a system if the input
and output signals are known. In this case, the command is ℎ = 𝑑𝑒𝑐𝑜𝑛𝑣(𝑦, 𝑥).
Discrete-time Convolution
In this section, several examples on computing the convolution between two discrete-time signals by using
the command conv are given. There are two basic principles that should be considered when commutating
the convolution between two discrete-time signals
The Two Principles of Convolution
1. Suppose that the length of vector x is N and the length of vector h is M. The outcome of the
command 𝑦 = 𝑐𝑜𝑛𝑣(𝑥, ℎ) is a vector y of length 𝑀 + 𝑁 − 1. In other words, 𝑙𝑒𝑛𝑔𝑡ℎ(𝑦) =
𝑙𝑒𝑛𝑔𝑡ℎ(𝑥) + 𝑙𝑒𝑛𝑔𝑡ℎ(ℎ) − 1.
2. If the nonzero values of 𝑥[𝑛] are in the interval [𝑎𝑥, 𝑏𝑥] and the nonzero values of ℎ[𝑛] are in the
interval [𝑎ℎ, 𝑏ℎ], then the nonzero values of the output 𝑦[𝑛] are in the interval [𝑎𝑥 + 𝑎ℎ, 𝑏𝑥 + 𝑏ℎ]
Remarks
The commutatively property is not valid for the deconv command; hence, the output signal must be the first
input argument of the command deconv.
1. A system is described by the impulse response ℎ(𝑡) = 𝑡, 0 ≤ 𝑡 ≤ 10. Compute and plot the response
of the system to the input signal 𝑥(𝑡) = 0.8𝑡, 0 ≤ 𝑡 ≤ 10.
2. A system is described by the impulse response Compute and plot the response
of the system to the input signal 𝑥(𝑡) = 𝑢(𝑡) − 𝑢(𝑡 − 2).
3. Compute the input of system for which you have computed the system response in the above task
and verify the answer.
4. Compute the convolution between the complex sequence 𝑥 = [3 + 2𝑗, 1 + 𝑗, 4 + 6𝑗] 𝑎𝑛𝑑 ℎ = [1
− 2𝑗, 𝑗, 3 − 2𝑗, 2].
Lab Tasks
Lab Task
A linear time-invariant system is described by the impulse response
Lab Task
Suppose that a linear time-invariant (LTI) system is described by the impulse response ℎ(𝑡) = 𝑒−𝑡𝑢(𝑡).
Compute the response of the system to the input signal without using command.
0.6, −1 < 𝑡 < 0.5
𝑥(𝑡) = {0.3, 0.5 < 𝑡 < 3
0, 𝑡 < −1 𝑎𝑛𝑑 𝑡 > 3
Without using command compute the response of the system to the input signal
1, 0≤𝑛≤ 4
𝑥[𝑛 ]= {
0, 𝑒𝑙𝑠𝑒𝑤ℎ𝑒𝑟𝑒
Lab Task
Compute the impulse response of system for which you have computed the system response in the above task
and verify the answer.
The student performance for the assigned task during the lab session was:
The student completed assigned tasks without any help from
Excellent 4
the instructor and showed the results appropriately.
The student completed assigned tasks with minimal help from the
Good 3
instructor and showed the results appropriately.
The student could not complete all assigned tasks and showed
Average 2
partial results.
Worst The student did not complete assigned tasks. 1
Objectives
After completing this lab, the student will be able to:
✓ Construct the complex exponential fourier series coefficients.
✓ Display the line spectrum of periodic signals.
Pre-Lab
Fourier series of Periodic Signals
Periodic Signals
We define a continuous-time signal 𝑥(𝑡) to be periodic if there is a positive
The fundamental period 𝑇0 of 𝑥(𝑡) is the smallest positive value of T is satisfied, and = is referred to
as the fundamental frequency.
Two basic examples of periodic signals are the real sinusoidal signal:
Time Shifting
A shift in time of the periodic signal results on a phase change of the Fourier series coefficients. So if
Time Reversal
This property states that if then .
Signal Multiplication
The Fourier series coefficients of the product of two signals equal the convolution of the Fourier series
coefficients of each signal. Suppose that 𝑥(𝑡) ↔ 𝑎𝑘 and 𝑦(𝑡) ↔ 𝑏𝑘 then,
Parseval’s Identity
The Parseval’s Identity states that the average power of a periodic signal is 𝑥(𝑡) with period equals the sum of the
squares of the complex exponential Fourier series coefficients.
Mathematically,
Plot in one period the approximate signals using 41 and 201 terms of the complex exponential Fourier
series. Furthermore, each time plot the complex exponential coefficients.
Lab Tasks
Lab Task
Using the complex exponential Fourier series representation, calculate the Fourier Series Coefficients of the
periodic signal shown below. Approximate by using 5, 11, 21 and 61 terms of FS coefficients ,
and compare the results. 𝑥(𝑡) In one period is given by:
Lab Task
We repeat the previous example for trigonometric Fourier series representation and compute the Fourier
series coefficients for various numbers of trigonometric terms used.
Lab Task
To verify time shifting property, we consider the periodic signal that in one period is given by: 𝑥(𝑡) =
𝑡𝑒−5𝑡, 0 ≤ 𝑡 ≤ 10. Moreover we set 𝑡1 = 3. Consequently the signal 𝑥(𝑡) = (𝑡 − 𝑡1) is given by 𝑥(𝑡) =
(𝑡 − 𝑡1) = 𝑥(𝑡 − 3) = (𝑡 − 3)𝑒−5(𝑡−3).
Lab Task
To verify signal multiplication property we consider the signals 𝑥(𝑡) = 𝑐𝑜𝑠(𝑡) and 𝑦(𝑡) = 𝑠𝑖𝑛(𝑡).
The student performance for the assigned task during the lab session was:
The student completed assigned tasks without any help from
Excellent 4
the instructor and showed the results appropriately.
The student completed assigned tasks with minimal help from the
Good 3
instructor and showed the results appropriately.
The student could not complete all assigned tasks and showed
Average 2
partial results.
Worst The student did not complete assigned tasks. 1
Objectives
After completing this lab, the student will be able to:
✓ Trace the output response of CTFT in MATLAB.
Pre Lab
In other words, the Fourier transform of a signal 𝑥(𝑡) is a signal 𝑋(𝜔). An alternative way of writing is
It is clear that 𝑋(𝜔) is a complex function of . In case of the Fourier transform of has to be express in
the frequency domain , then substituting by 2𝜋𝑓 yields
In order to return from frequency domain to back time domain the inverse Fourier transform is applied. The
inverse Fourier transform is denoted by the symbol ; that is, one can write
Or alternatively
Using instead of ,
The cyclic frequency is measured in rad/s, while is measured in Hertz. The Fourier transform of a signal is
called (frequency) spectrum.
Linearity
If and then for any scalar and the following property stands:
Time Shifting
If 𝑋(𝜔) = 𝐹{𝑥(𝑡)} then for any
Frequency Shifting
If then for any ,
and
The natural meaning of this property is that if the signal is expanded in time , then its spectrum is
compressed to lower frequencies. On the other hand, a time compression of a signal results in
an expansion of the signal spectrum to higher frequencies.
Time Reversal
If , then
Integration
If , then
Duality
If , then
a.
b.
1 0≤𝑡< 1
c. 𝑥(𝑡) = 0 1 ≤ 𝑡 < 2
1 2≤𝑡< 3
2
2. Compute and plot the convolution between the signals𝑥(𝑡) = 𝑒−𝑡 andℎ(𝑡) = 𝑒−𝑡𝑢(𝑡) + 𝑒𝑡𝑢(−𝑡).
Lab Tasks
Lab Task
Compute the Fourier transform of the function
Lab Task
Compute the inverse Fourier transform of the function .
Lab Task
Plot the Fourier transform of the continuous-time signal𝑥(𝑡) =
Lab Task
Compute the convolution between the signals and .
The student performance for the assigned task during the lab session was:
The student completed assigned tasks without any help from
Excellent 4
the instructor and showed the results appropriately.
The student completed assigned tasks with minimal help from the
Good 3
instructor and showed the results appropriately.
The student could not complete all assigned tasks and showed
Average 2
partial results.
Worst The student did not complete assigned tasks. 1
Objectives
After completing this lab, the student will be able to:
✓ Trace the output response of DTFT in MATLAB.
Pre- Lab
The DTFT representation of a sequence, if it exists, is unique and the original sequence can be computed from
its DTFT by inverse transformation operation.
In general 𝑋(𝑒𝑗𝜔) is complex function of the real variable w and can be written in the rectangular form as
𝑋(𝑒𝑗𝜔) = |𝑋(𝑒𝑗𝜔)|𝑒𝑗𝜃(𝜔)
𝜃(𝜔) = arg{𝑋(𝑒𝑗𝜔)}
The quantity |𝑋(𝑒𝑗𝜔) is called Magnitude function and the quantity 𝜃(𝜔) is called Phase function. Note that
if we replace 𝜃(𝜔) with 𝜃(𝜔)+2𝜋𝑘, where k is any integer, 𝑋(𝑒𝑗𝜔) remains unchanged implying that phase
function cannot be uniquely specified for any Fourier Transform. Unless otherwise stated, we will assume that
the phase function 𝜃(𝜔) is restricted to the following range of values
Convergence Condition
The Fourier Transform 𝑋(𝑒𝑗𝜔) of a sequence 𝑥[𝑛] is said to exist if converges in some sense.
If 𝑥[𝑛] is absolutely sum able sequence, i.e if
Then
Lab Tasks
Lab Task
Find the real part, imaginary part, magnitude and phase of the following DTFT 𝑋(𝑒𝑗𝜔) for the equally spaced
K points between 0 and Value of K=256.
The student performance for the assigned task during the lab session was:
The student completed assigned tasks without any help from
Excellent 4
the instructor and showed the results appropriately.
The student completed assigned tasks with minimal help from the
Good 3
instructor and showed the results appropriately.
The student could not complete all assigned tasks and showed
Average 2
partial results.
Worst The student did not complete assigned tasks. 1
Objectives
After completing this lab, the student will be able to:
✓ Explain the output of Laplace Transform using MATLAB.
Pre Lab
.
Variable s is a complex-valued number, and thus can be written as 𝑠=𝑎+𝑗𝜔. This relationship reveals the association
between the Laplace transform and the Fourier transform. More specially, substituting S by 𝑗𝜔 yields the Fourier
transform 𝑋(𝜔) of 𝑥(𝑡). Setting the lower limit of the integral to zero yields the one-sided (or unilateral) Laplace
transform, which is described by the relationship
.
The use of the one-sided Laplace transform is better suited for the purpose of this lab, as the signals considered
are usually casual signals. In order to return from the -domain back to the time domain, the inverse Laplace
transform is applied. The inverse Laplace transform is denoted by the symbol 𝐿−1{. }, that is, one can write
𝑓(𝑡) = 𝐿−1{𝐹(𝑠)},
Or alternatively
The mathematically expression that describes the inverse Laplace transform of a function 𝐹(𝑠) is
Region of Convergence
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 100
FIGURE 10.1: Region of convergence of the Laplace transformof
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 101
Inverse Laplace Transform through Partial Fraction
Partial Fraction of a Rational Function
In the usual case, the Laplace Transform of a function is expressed as a rational function of .that is, is given
as a ratio of two polynomials of . The mathematical expression is
Where 𝑎𝑖 and 𝑏𝑖 are real scalars. First, we discuss the case 𝑚 < 𝑛; that is, the case that the degree of
polynomial 𝐵(𝑠) of the numerator is lower than the degree of the polynomial 𝐴(𝑠) of the denominator.
Suppose that 𝜆𝑖 are the roots of 𝐴(𝑠). The following case is considered:
The roots are 𝜆𝑖 distinct; that is, every root appears only once. In this case, 𝐴(𝑠) is written in the factored
form 𝑖=1 while 𝑋(𝑠) is written as
𝑐1 𝑐2 𝑐𝑛
𝑋(𝑠) = + +⋯+
𝑠 − 𝜆1 𝑠 − 𝜆2 𝑠 − 𝜆𝑛
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 102
The Command residue
We introduced a procedure that has to be followed in order to express a function from rational form to partial
fraction form. Alternatively, this procedure can be implemented directly in MATALB by using the command
residue. The syntax is [𝑅, 𝑃, 𝐾] = 𝑟𝑒𝑠𝑖𝑑𝑢𝑒(𝐵, 𝐴), where B is a vector containing the coefficients of the
numerator polynomial and A is the vector of the coefficients of the denominator polynomial. Suppose that a
signal is written in the rational form.
By defining the vectors 𝐵 = [ 𝑏𝑚, … , 𝑏0] and 𝐴 = [ 𝑎𝑚, … , 𝑎0], and executing the command [𝑅, 𝑃, 𝐾] =
𝑟𝑒𝑠𝑖𝑑𝑢𝑒(𝐵, 𝐴), the signal 𝑋(𝑠) can be written in partial fraction form as
Where
K is the residue of the division of the two polynomials. K is null when 𝑚 < 𝑛.
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 103
Lab Tasks
Lab Task
Compute the Laplace transform of the function 𝑓(𝑡) = −1.25 + 3.5𝑡𝑒−2𝑡 + 1.25𝑒−2𝑡. Confirm your answer
by evaluating the inverse Laplace transform of the result.
Lab Task
Compute the inverse Laplace transform of the function
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 104
Lab Task
Express in the partial fraction form of the signal
Verify your result by computing the inverse Laplace transform from both forms (partial fraction and rational)
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 105
Rubric for Lab Assessment
The student performance for the assigned task during the lab session was:
The student completed assigned tasks without any help from
Excellent 4
the instructor and showed the results appropriately.
The student completed assigned tasks with minimal help from the
Good 3
instructor and showed the results appropriately.
The student could not complete all assigned tasks and showed
Average 2
partial results.
Worst The student did not complete assigned tasks. 1
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 106
LAB # 11: To Reproduce the Properties of Laplace Transform Using MATLAB
Functions
Objectives
After completing this lab, the student will be able to:
✓ Follow the steps involved in verification of properties of Laplace Transform in MATLAB.
Pre Lab
Linearity
Let 𝑋1(𝑠) = 𝐿{𝑥1(𝑡)} and 𝑋2(𝑠) = 𝐿{𝑥2(𝑡)}. Then for any scalars 𝑎1, 𝑎2 the following property stands
𝐿{𝑎1𝑥1(𝑡) + 𝑎2𝑥2(𝑡)} = 𝑎1𝑋1(𝑠) + 𝑎2𝑋2(𝑠)
syms t s
x1=exp(-t);
x2=cos(t);
a1=3;
a2=4;
Le=a1*x1+a2*x2;
Left=laplace(Le,s)
X1=laplace(x1);
X2=laplace(x2);
Right=a1*X1+a2*X2
Left =
3/(s + 1) + (4*s)/(s^2 + 1)
Right =
3/(s + 1) + (4*s)/(s^2 + 1)
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 107
Time Shifting
If 𝑋(𝑠) = 𝐿{𝑥(𝑡)𝑢(𝑡)} , then for any 𝑡0 > 0
syms t s
t0=2;
%x(t)=cos(t)u(t)
Le=cos(t-t0)*heaviside(t-t0);
Left=simplify(laplace(Le))
X=laplace(cos(t),s);
Right=exp(-s*t0)*X
X=laplace(cos(t),s);
Right=exp(-s*t0)*X
Left =
(s*exp(-2*s))/(s^2 + 1)
Right =
(s*exp(-2*s))/(s^2 + 1))
syms t s
x=t.^3;
s0=2;
f=x*exp(s0*t);
L=laplace(f,s)
X=laplace(x,s);
R=subs(X,s,s-2)
L =
6/(s - 2)^4
R =
6/(s - 2)^4
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 108
Time Scaling
If 𝑋(𝑠) = 𝐿{𝑥(𝑡)𝑢(𝑡)} then for any 𝑏 > 0
syms t s b
le=exp(-b*2*t);
L=laplace(le,s)
x=exp(-2*t);
X=laplace(x,s);
R=simplify((1/b)*subs(X,s,s/b))
L =
1/(2*b + s)
R =
1/(2*b + s)
Differentiation in s-domain
If 𝑋(𝑠) = 𝐿{𝑥(𝑡)} and 𝑛 = 1,2, … then
syms t s
%n=5
x=exp(t);
f=((-t)^5)*x;
L=laplace(f,s)
x=laplace(x,s);
R=diff(X,5)
L =
-120/(s - 1)^6
R =
-120/(s + 2)^6
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 109
Integration in the Complex Frequency
If 𝑋(𝑠) = 𝐿{𝑥(𝑡)} then
syms s t u
x=sin(t);
L=laplace(x/t,s);
subplot(121)
ezplot(L,[0 100])
X=laplace(x,u);
R=int(X,u,s,inf);
subplot(122)
ezplot(R,[0 100])
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 110
Lab Tasks
Lab Task
Compute the convolution between the signals 𝑥(𝑡) = 5𝑒−𝑡𝑢(𝑡) and ℎ(𝑡) = 𝑡𝑒−𝑡𝑢(𝑡).
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 111
Rubric for Lab Assessment
The student performance for the assigned task during the lab session was:
The student completed assigned tasks without any help from
Excellent 4
the instructor and showed the results appropriately.
The student completed assigned tasks with minimal help from the
Good 3
instructor and showed the results appropriately.
The student could not complete all assigned tasks and showed
Average 2
partial results.
Worst The student did not complete assigned tasks. 1
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 112
LAB # 12: To Measure the Response of Discrete-Time Signals Using Z-Transform
in MATLAB
Objectives
After completing this lab, the student will be able to:
✓ Manipulate and measure the output of Z-Transform using MATLAB.
Pre Lab
𝐹(𝑧) = 𝑍{𝑓[𝑛]}
In other words, the z-transform of a function 𝑓[𝑛] is 𝐹(𝑧). The mathematical expression of the two sided (or-
bilateral) z-transform is
∞
𝐹(𝑧) = 𝑍{𝑓[𝑛]} = ∑ 𝑓[𝑛]𝑧−𝑛
𝑛=−∞
Where z is a complex variable. Setting the lower limit of the sum from minus infinity to zero yields the one-
sided (or unilateral) z-transform whose mathematical expression is
∞
𝐹(𝑧) = 𝑍{𝑓[𝑛]} = ∑ 𝑓[𝑛]𝑧−𝑛
𝑛=−∞
In order to return from the z-domain back to the discrete-time domain, the inverse z-transform is applied. The
inverse z-transform is denoted by the symbol 𝑍−1{. }; that is, one can write
𝑓[𝑛] = 𝑍−1{𝐹(𝑧)}
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 113
Commands ztrans and iztrans
Region of Convergence
Z- Transform Pairs
In this section, the most common z-transform pairs are presented. In the general case, the z-transform or the
inverse z-transform of a function cannot be easily computed directly. This is the reason that already computed
z-transform pairs are used to compute the z-transform or the inverse z-transform of a complicated function.
Thus, the computational procedure is to express a complicated function of interest in terms of functions with
known z (or inverse z) transform and then based on the properties of z-transform to compute the z (or inverse
z) transform of the complicated function. In the table below, the most common z-transform pairs are given.
The illustrated pairs are confirmed by using the commands ztrans and iztrans. It should be noted that since
the command ztrans computes the one sided z-transform ( ), the unit step sequence 𝑢[𝑛] can be
omitted from the signal definition.
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 114
Inverse Z-Transform through Partial Fraction
Partial Fraction Expansion of a Rational Function
The z-transform of a sequence is usually expressed as a rational function of i.e., it is written as a ratio of two
polynomials of z. The mathematical expression is
Where 𝑎𝑖, 𝑏𝑖 are real numbers. In order to express the function 𝑋(𝑧) in a partial fraction form, we follow a
similar approach to that followed in the Laplace transform chapter.
A signal in rational form can be expressed in partial fraction form by using the command residue. The command
residue is used to confirm the result of the previous example.
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 115
Lab Tasks
Lab Task
Compute the z-transform of the sequence 𝑓[𝑛] = [−3,5,6,7,8], −2 ≤ 𝑛 ≤ 2.
Lab Task
Compute the z-transform of the discrete-time signal 𝑥[𝑛] = 𝑛2𝑢[𝑛].
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 116
Lab Task
Confirm your result of task 2, by computing the inverse z-transform of your outcome.
Lab Task
Find the inverse z-transform of 𝑋(𝑧) = 2𝑧+3
𝑧2 +5𝑧+6
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 117
Rubric for Lab Assessment
The student performance for the assigned task during the lab session was:
The student completed assigned tasks without any help from
Excellent 4
the instructor and showed the results appropriately.
The student completed assigned tasks with minimal help from the
Good 3
instructor and showed the results appropriately.
The student could not complete all assigned tasks and showed
Average 2
partial results.
Worst The student did not complete assigned tasks. 1
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 118
LAB # 13: To Reproduce the Properties of Z-Transform Using MATLAB
Functions
Objectives
After completing this lab, the student will be able to:
✓ Follow the steps involved in verification of properties of Z-Transform in MATLAB.
Pre Lab
Linearity
If 𝑋1(𝑧) = 𝑍{𝑥1[𝑛]} and 𝑋2(𝑧) = 𝑍{𝑥2[𝑛]}, then for any scalar 𝑎1, 𝑎2.
syms n z
x1=n^2;
x2=2^n;
a1=3;
a2=4;
Le=a1*x1+a2*x2;
Left=ztrans(Le,z)
X1=ztrans(x1,z);
X2=ztrans(x2,z);
Right=a1*X1+a2*X2
Left =
Right =
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 119
Right Shift
If 𝑋(𝑧) = 𝑍{𝑥[𝑛]} and 𝑥[𝑛] is casual, i.e., 𝑥[𝑛] = 0, 𝑛 < 0, then for any positive integer 𝑚,
𝑍{𝑥[𝑛 − 𝑚]𝑢[𝑛 − 𝑚]} = 𝑧−𝑚𝑋(𝑧)
syms n z
m=2;
x1=3^(n-m)*heaviside(n-m);
Left=simplify(ztrans(x1,z))
x=3^n*heaviside(n);
X=ztrans(x,z);
Right=simplify((z^(-m))*X)
Left =
(3/(z - 3) + 1/2)/z^2
Right =
(3/(z - 3) + 1/2)/z^2
Right Shift
If 𝑋(𝑧) = 𝑍{𝑥[𝑛]}, then for any positive integer 𝑚,
syms z n
xn2=0.8^(n-2);
Left=simplify(ztrans(xn2,z))
x=0.8.^n;
X=ztrans(x,z);
Right=simplify((z^-2)*X+xminus2+(z^-1)*xminus1)
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 120
Left =
(25*z)/(16*(z - 4/5))
Right =
(125*z)/(16*(5*z - 4))
Left shift
x0=0.8^(0);
x1=0.8^(1);
syms n z
xn2=0.8^(n+2);
Left=simplify(ztrans(xn2,z))
x=0.8^n;
X=ztrans(x,z);
Right=simplify((z^2)*X-(z^2)*x0-x1*z)
Left =
(16*z)/(25*(z - 4/5))
Right =
(16*z)/(5*(5*z - 4))
𝑍{𝑎−𝑛𝑥[𝑛]} = 𝑋(𝑎𝑧)
And
An important special case is when 𝑎 = 𝑒𝑗𝜔0 , for which 𝑍{𝑒𝑗𝜔0𝑛𝑥[𝑛]} = 𝑋(𝑒−𝑗𝜔0 𝑧).
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 121
syms n z a w0
x=4^n;
X=ztrans(x,z);
%case 1
Right=subs(X,z,a*z)
L=a^(-n)*x;
Left=simplify(ztrans(L,z))
%case 2
Right=simplify(subs(x,z,z/a))
L=a^n*x;
Left=simplify(ztrans(L,z))
%case 3
Right=subs(X,z,exp(-j*w0)*z);
L=exp(j*w0*n)*x;
Left=simplify(ztrans(L,z));
error=simplify(Left-Right)
Right =
(a*z)/(a*z - 4)
Left =
(a*z)/(a*z - 4)
Right =
2^(2*n)
Left =
-z/(4*a - z)
error = 0
Time Reversal
If 𝑋(𝑧) = 𝑍{𝑥[𝑛]} then
𝑍{𝑥[−𝑛]} = 𝑋(𝑧−1)
syms z
x=[1 2 3 4];
n=[0 1 2 3];
X=sum(x.*(z.^-n));
Right=subs(X,z,z^-1)
nrev=[-3 -2 -1 0];
xrev=[4 3 2 1];
Left=sum(xrev.*(z.^nrev))
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 122
Right =
Left =
syms n z
x=0.9^n;
Left=ztrans(n*x,z)
X=ztrans(x,z);
d=diff(X,z);
Right=simplify(-z*d)
Left =
(90*z)/(10*z - 9)^2
Right =
(90*z)/(10*z - 9)^2
Summation
If 𝑋(𝑧) = 𝑍{𝑥[𝑛]} and 𝑥[𝑛] is a casual discrete-time signal, then
syms n z
x=n^2;
s=symsum(x,n,0,n);
Left=simplify(ztrans(s,z))
X=ztrans(x,z);
Right=(z/(z-1))*X
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 123
Left =
Right =
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 124
Convolution in the time domain
If 𝑋1(𝑧) = 𝑍{𝑥1[𝑛]} and𝑋2(𝑧) = 𝑍{𝑥2[𝑛]}, then
n=0:50;
x1=0.9.^n;
x2=0.8.^n;
y=conv(x1,x2);
subplot(121)
stem(0:100,y)
legend('Convolution');
syms n z
x1=0.9.^n;
x2=0.8.^n;
X1=ztrans(x1,z);
X2=ztrans(x2,z);
Right=iztrans(X1*X2);
n=0:100;
Right=subs(Right,n);
subplot(122)
stem(0:100,Right)
legend('Z^-^1[X_1(z)*X_2(z)]')
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 125
Pre Lab Tasks
1. Compute the convolution between the signals,
Lab Tasks
Lab Task:
Compute the convolution between the signals,
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 126
Rubric for Lab Assessment
The student performance for the assigned task during the lab session was:
The student completed assigned tasks without any help from
Excellent 4
the instructor and showed the results appropriately.
The student completed assigned tasks with minimal help from the
Good 3
instructor and showed the results appropriately.
The student could not complete all assigned tasks and showed
Average 2
partial results.
Worst The student did not complete assigned tasks. 1
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 127
LAB # 14: To Construct the Digital Filters Using Direct Form I & II in MATLAB
Objectives
After completing this lab, the student will be able to:
✓ Distinguish between FIR and IIR filters using mathematical equations.
✓ Manipulate and construct the digital filters using design strategies.
Pre Lab
To process signals, we have to design and implement systems called filters .The filter design issue is influenced
by such factors as the type of the filter (i.e., IIR or FIR) or the form of its implementation (structures). Hence
before we discuss the design issue, we first concern ourselves with how these filters can be implemented in
practice. This is an important concern because different filter structures dictate different design strategies.
IIR filters are characterized by infinite duration impulse responses. Some of these impulse responses can be
modeled by rational system functions or, equivalently, by difference equations. Such filters are termed as
auto-regressive moving average (ARMA) or, more generally, as recursive filters. Those IIR filters that cannot
be so modeled are called non-recursive filters. In DSP, IIR filters generally imply recursive ones because these
can be implemented efficiently. Therefore we will always use the term IIR to imply recursive filtered
Furthermore, ARMA filters include moving average filters that are FIR filters. However, we will treat FIR filters
separately from IIR filters for both design and implementation purposes.
where 𝑏𝑛 and 𝑎𝑛, are the coefficients of the filter. We have assumed without loss of generality that
. The difference equation representation of an IIR filter is expressed as
Direct form: In this form the difference equation is implemented directly as given. There are two parts to this
filter, namely the moving average part and the recursive part (or equivalently, the numerator and denominator
parts). Therefore this implementation leads to two versions: direct form I and direct form I1 structures.
Following figures shows the two types of direct forms.
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 128
Figure: Direct form I structure
Cascade Form: In this form the system function 𝐻(𝑧) as mentioned in above equation is factored into smaller
second order sections, called biquads. The system function is then represented as a product of these biquads.
Each biquad is implemented in a direct form, and the entire system function is implemented as a cascade of
biquad sections.
Parallel Form: This is similar to the cascade form, but after factorization, a partial expansion is used to
represent 𝐻(𝑧) as a sum of smaller second-order sections. Each section is again implemented in a direct form,
and the entire system function is implemented as a parallel network of sections.
MATLAB Implementation
For signals and System course we will limit the implementation of filter structures to only direct form and rest
of the types will be covered in Digital Signal Processing (DSP) course.
A routine called filter is available in MATLAB to implement the IIR filter (also to solve the difference equation)
numerically, given the input and the coefficients of the filter. In its simplest form this routine is invoked by
Where
are the coefficient arrays of the IIR filter, and 𝑥 is the input sequence array. The output 𝑦 has the same length
as input 𝑥. One must ensure that the coefficient t not be zero. We illustrate the use of this routine in the
following example.
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 129
c. Is the system specified by ℎ[𝑛] stable?
From the given difference equation the coefficient arrays are 𝑏 = [1,0.3]; 𝑎 = [1, −1,0.9].
b=[1,0.3];
a=[1,-
1,0.9];
n0=0;
n1=- 20;
n2=120;
%x = [zeros(1,(n0-n1)), 1, zeros(1,(n2-n0))];
x = [(n-n0) == 0];
h=filter(b,a,x);
subplot(2,1,1);
stem(n,h)
title('impulse response')
xlabel('n');
ylabel('h(n)');
%x = [zeros(1,(n0-n1)), ones(1,(n2-n0+1))];
x = [(n-n0)>=0];
To determine the stability of the system, we have to determine ℎ[𝑛] for all n. Although we have not described
a method to solve the difference equation, we can use the plot of the impulse response to observe that ℎ[𝑛]
is practically zero for 𝑛 > 120. Hence the sum |ℎ[𝑛]| can be determined from MATLAB using
𝒔𝒖𝒎(𝒂𝒃𝒔(𝒉)) which implies that the system is stable. An alternate approach is to use the stability condition
using MATLAB ‘ ’ function, 𝒛 = 𝒓𝒐𝒐𝒕𝒔(𝒉) & 𝒎𝒂𝒈𝒛 = 𝒂𝒃𝒔(𝒛). Since all the roots obtained
through above MATLAB code is less than one so the system is stable.
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 130
and the difference equation representation is
𝑦[𝑛] = 𝑏0𝑥[𝑛] + 𝑏1𝑥[𝑛 − 1] + ⋯ + 𝑏𝑀−1𝑥[𝑛 − 𝑀 + 1]
which is a linear convolution of finite support. The order of the filter is 𝑀 − 1, while the length of the filter
(which is equal to the number of coefficients) is M. The FIR filter structures are always stable, and they are
relatively simple compared to IIR structures. Moreover, FIR filters can be designed to have a linear-phase
response, which is desirable in some applications.
Direct Form: In this form the difference equation is implemented directly as given.
Cascade Form: In this form the system function 𝐻(𝑧) in is factored into second-order factors, which are then
implemented in a cascade connection.
Linear-Phase Form: When an FIR filter has a linear phase response; its impulse response exhibits certain
symmetry conditions. In this form we exploit these symmetry relations to reduce multiplications by about half.
Frequency Sampling Form: This structure is based on the DFT of the impulse response ℎ[𝑛] and leads to a
parallel structure. It is also suitable for a design technique based on the sampling of frequency
response 𝐻(𝑒𝑗𝑤).
MATLAB Implementation
In MATLAB the direct form FIR structure is described by the row vector b containing the {𝑏𝑛} coefficients. The
structure is implemented by the filter function, in which the vector is set to the scalar value 1 and rest of the
implementation will be the same as discussed above in IIR implementation section.
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 131
Lab Tasks
Lab Task
A causal linear time-invariant system is described by
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 132
Lab Task
An FIR filter is described by the difference equation
Determine and draw the block diagrams of the following structures using Direct form.
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 133
Rubric for Lab Assessment
The student performance for the assigned task during the lab session was:
The student completed assigned tasks without any help from
Excellent 4
the instructor and showed the results appropriately.
The student completed assigned tasks with minimal help from the
Good 3
instructor and showed the results appropriately.
The student could not complete all assigned tasks and showed
Average 2
partial results.
Worst The student did not complete assigned tasks. 1
Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 134