Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
975 views135 pages

CPE223-Signals and Systems Lab Manual

CPE223-Signals and Systems Lab Manual
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
975 views135 pages

CPE223-Signals and Systems Lab Manual

CPE223-Signals and Systems Lab Manual
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 135

COMSATS University Islamabad, Lahore Campus

Department of Electrical and Computer Engineering

CPE223 – Signals and Systems


Lab Manual for FALL 2020

Lab Resource Person


Umair Shafiq Khan

Theory Resource Person


Muhammad Usman Iqbal

Supervised By
Dr. Khurram Ali

Name: Registration Number:

Program: Batch:

Semester
Revision History

S.No. Updated By Date Reviewed By

1 Lab Manual Preparation Sep-12 Mr. Muhammad Ijaz

2 Lab Manual Review Sep-12 Dr. Ejaz Ahmad Ansari

Lab Manual March-15 Ms. Tabassum Nawaz

3 Modifications Bajwa

Mr. Assad Ali

4 Lab Manual Review March-15 Dr. Ejaz Ahmad Ansari

5 Lab Manual Modification Sep -15 Muhammad Usman


Iqbal

6 Lab Manual Review Sep-15 Dr. Ejaz Ahmad Ansari

7 Lab Manual Modification Aug-16 Mr. Assad Ali

Ms. Maida Farooq

8 Lab Manual Review Aug-16 Dr. Khurram Ali

9 Lab Manual Modification Sep-17 Ms. Maida Farooq

10 Lab Manual Review Sep-17 Dr. Khurram Ali

11 Lab Manual Modification Feb-2020 Ms. Sidra Saleem

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.

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual iv


Books
Text Books
1. Continuous and Discrete Time Signals and System by Mrinal Mandal and Amir Asif, Latest Edition,
Cambridge.

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.

Reference Books for Manual


1. Signals and System Laboratory with MATLAB by Alex Palamides and Anastasia Veloni.

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

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual v


Grading Policy

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 Report Instructions


All questions should be answered precisely to get maximum credit. Lab report must ensure following items:

✓ Lab objectives
✓ MATLAB codes
✓ Results (graphs/tables) duly commented and discussed ✓ Conclusion

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual vi


Safety Instructions
1. Conduct yourself in a responsible manner at all times in the laboratory. Don’t talk aloud or crack jokes
in lab.
2. Know the location of electrical panels and disconnect switches in or near your laboratory so that
power can be quickly shut down in the event of a fire or electrical accident
3. Report any damages to equipment, hazards, and potential hazards to the laboratory instructor.
4. If in doubt about electrical safety, see the laboratory instructor. Regarding specific equipment, consult
the instruction manual provided by the manufacturer of the equipment. Information regarding safe
use and possible- hazards should be studied carefully.
5. Make sure that the computers should be properly turned off when you complete your lab task.
6. Make sure that the software used in Lab is properly handled.
7. During any problem regarding software consult the Lab instructor.
8. Do not eat food, drink beverages or chew gum in the laboratory and do not use laboratory glassware
as containers for food or beverages. Smoking is strictly prohibited in lab area.
9. Do not open any irrelevant internet sites on lab computer.
10. Do not use a flash drive on lab computers.
11. Do not upload, delete or alter any software on the lab PC.

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

Learning Outcome Relevant Experiment

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 CLOs – Lab Experiment Mapping


Lab 10

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

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual ix


Table of Contents

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 xi


Pre Lab ................................................................................................................................................................. 69
Computation of Continuous-Time Convolution .............................................................................................. 69
De-convolution of Continuous-Time Signals ................................................................................................... 69
Computation of Discrete-Time Convolution ................................................................................................... 70
De-convolution of Discrete-Time Signals ........................................................................................................ 70
Pre Lab Tasks ....................................................................................................................................................... 70
Lab Tasks ............................................................................................................................................................. 71
LAB # 7: To Sketch the Line Spectrum of Periodic Signals Using Properties of Fourier Series Coefficients in
MATLAB ............................................................................................................................................................... 77
Objectives ............................................................................................................................................................ 77
Pre-Lab ................................................................................................................................................................ 77
Fourier series of Periodic Signals ..................................................................................................................... 77
Pre Lab Tasks ....................................................................................................................................................... 80
Lab Tasks ............................................................................................................................................................. 80
LAB # 8: To Reproduce the Continuous Time Fourier Transform (CTFT) Using MATLAB Functions .................. 87
Objectives ............................................................................................................................................................ 87
Pre Lab ................................................................................................................................................................. 87
Introduction to Fourier Transform .................................................................................................................. 87
The Command fourier and ifourier ................................................................................................................. 87
Fourier Transform Pairs ................................................................................................................................... 88
Properties of Fourier Transform ...................................................................................................................... 89
Pre Lab Task......................................................................................................................................................... 90
Lab Tasks ............................................................................................................................................................. 90
LAB # 9: To Reproduce the Discrete Time Fourier Transform (DTFT) Using MATLAB Functions ....................... 94
Objectives ............................................................................................................................................................ 94
Pre- Lab................................................................................................................................................................ 94
Discrete Time Fourier Transform (DTFT) ......................................................................................................... 94
Pre Lab Tasks ....................................................................................................................................................... 95
Lab Tasks ............................................................................................................................................................. 95
LAB # 10: To Show the Response of Continuous Time Signals Using Laplace Transform in MATLAB ................ 99
Objectives ............................................................................................................................................................ 99
Pre Lab ................................................................................................................................................................. 99
Laplace and Inverse Laplace Transform .......................................................................................................... 99
Command Laplace and ilaplace ..................................................................................................................... 100
Region of Convergence.................................................................................................................................. 100
Laplace Transform Pairs ................................................................................................................................ 101
Inverse Laplace Transform through Partial Fraction ..................................................................................... 102
Pre Lab Task....................................................................................................................................................... 103
Lab Tasks ........................................................................................................................................................... 104
LAB # 11: To Reproduce the Properties of Laplace Transform Using MATLAB Functions ................................ 107
Objectives .......................................................................................................................................................... 107
Pre Lab ............................................................................................................................................................... 107
Laplace Transform Properties and Theorems ............................................................................................... 107
Pre Lab Task....................................................................................................................................................... 110
Lab Tasks ........................................................................................................................................................... 111
LAB # 12: To Measure the Response of Discrete-Time Signals Using Z-Transform in MATLAB ....................... 113

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:

✓ Describe the basic operations and commands in MATLAB.


✓ Describe the steps involved in plotting the Continuous and Discrete time signals in MATLAB.

Pre Lab

Part I –Introduction to MATLAB


What is MATLAB?
MATLAB is a high-level technical computing language equipped with a user-friendly interface. Its name stems
from the words MATrix and LABoratory as it is based on the use of matrices. MATLAB is an extremely powerful
tool useful for scientists and engineers from various disciplines. For example, MATLAB can be used in a wide
range of applications, such as telecommunications, signal and image processing, control, mathematics,
financial modeling, bioengineering, aeronautics, and many more.

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.

% Program to understand the use of script file


% 𝑓(𝑡) = 𝑡𝑐𝑜𝑠(2𝜋𝑡), -5 ≤ 𝑡 ≤ 5

t=-5:0.1:5;
f=t.*cos(2*pi*t);
plot(t,f)

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 15


Functions
Functions are also M-files, That is, are files with extension .m and must be saved in the current Directory of
MATLAB. The difference between functions and scripts is that a function accepts one or more input arguments
and returns one or more output arguments. To declare that an M-file is a function the first line of the m file
must contain the syntax definition. More specifically, the first line of the M-file must be of the form function
[y1,y2,y3,…yn] = name(x1,x2,x3… xm). The variable y1,y2,…yn are the outputs of the function while x1,x2,…xm
are the input arguments. In case there is only one output, the square brackets are not necessary. The “name”
specifies the name of the function. In order to execute a function, first the M-File is saved in Current Directory.

Lab Task
Write a function file and execute. Function should accepts as input two matrices and returns their sum and
product.

% Program to understand the use of a function file


% This function computes the sum and the product of 2 matrices

function [sm,pro]=oper(A,B)
sm=A+B;
pro=A*B;
end

% to test the function operation


% Enter the matric A
A= [ 2 3; 4 5]
% Enter Matrix B
B= [4 5; 5 6]

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

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 16


subtraction with the previous element. The command max and min return the largest and smallest elements of
the vector, respectively, as well as their index. The command sort sorts the vector elements in ascending (by
default) or descending order. The command mean computes the mean value, while the command median returns
the median value. All these commands are suitable also for matrices by slightly changing their syntax.

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.

mean(a) ans = 3.8000


%Mean value of the elements.

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.

Special Forms of Matrices


The command ones(M,N) creates a matrix of size MxN with ones. Typing ones(M) returns a square matrix with
ones. Similarly, the command zeros(M,N) creates a matrix of size MxN with zeros. The command rand(M,N)
returns an MxN matrix with random elements. The command eye(M,N) defines an MxN matrix with ones in
the main diagonal zeros everywhere. The command magic(M) creates a square matrix with the property that
the sum of each row or column is equal.

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 17


Commands Results/Comments
ones(2,3) ans = 1 1 1
1 1 1
%Matrix of size 2x3 with ones.
zeros(1,4)
ans = 0 0 0 0
%Matrix of size 1x4(or vector of length) with zeros.
rand(3)
ans = 0.8600 0.9000 0.4600
0.6000 0.1000 -0.3000
0.4540 0.6023 0.2700
%Matrix of size 3x3 with random elements. If there is one
input argument to the command, the obtained matrix is
square.
eye(4,2)
ans = 1 0
0 1
0 0
0 0
%Magic of size 4x2 with ones in the main diagonal and zeros
elsewhere.

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.

Part II- Plotting Signals in MATLAB


MATLAB is a very reliable and power full tool for plotting. A graph is constructed as a set of points in two or
three dimensions. These points are typically connected with a solid line. Commonly a graph of a function is
required. However in MATLAB a plot is done using the vectors and matrices not functions.

Plotting in Two Dimensions


Suppose that we want to plot a function 𝑦(𝑥), where 𝑥 is an independent variable. The procedure to plot
is as follows:

1. Vector x is created. Such as 𝑎 ≤ 𝑥 ≤ 𝑏, where a and b are scalars.


2. The function 𝑦(𝑥) will be plotted over the interval
3. Create the vector 𝑦 , which is of the same length as 𝑥. The two vectors have an equal number of
elements.
4. The value of each element of 𝑦 is the value of 𝑦(𝑥) calculated for each value of 𝑥.
5. Finally, the function is plotted by typing ‘plot(x,y)’

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 18


Lab Task
Plot the function 𝑦(𝑥) = 𝑥2, −2 ≤ 𝑥 ≤ 2

x=-2:2 % independent variable ,length of the plot


length (x)
y=x.^2 % Function
length (y)
plot(x,y)

x = -2 -1 0 1 2

ans = 5

y= 4 1 0 1 4

ans = 5

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 19


Write down modified MATLAB code to plot exactly like below

Plotting Several Function in One Figure


It is possible to plot more than one function in the name of figure by employing a different syntax of command
Plot.

Lab Task
Plot the in the same figure.

x = linspace(0,2*pi,100) % linspace could be used to create a vector.


x=0:pi/50:2*pi % this is same value as above. Both method are correct
y = (x.^2).*cos(x);
g = x.*cos(x);
f = (2.^x).*sin(x);
plot(x,y,x,g,x,f)

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 20


In the previous examples, the functions were plotted with predefined colors and line type (solid). It is possible
to create a graph using colors, symbols used to draw the points, and type of line that connects the points of
your choice. This is achieved by applying one more input argument to the command plot. The new argument
is a series of special character given in single quotes. The available special characters are presented in the
table below.

Symbols Color Symbol Point Type Symbol Line Type


B Blue . Point - Solid
G Green o Circle : Dotted
R Red x x-mark -. Dashdot
C Cyan + Plus _ Dashed
M Magenta * Star
Y Yellow s Square
K Black d Diamond
W White <,> Triangle
P Pentagram
h Hexagram

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.

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 21


% Program to understand formatting a plot: axis labeling, title and legend %

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')

Plotting in Different Figures


Up to this point, all plots were made in single figure named Figure 1. By typing at the command prompt figure,
a new figure with name Figure 2 appears without closing the old figures. The command subplot(m,n,p) or
subplot(mnp) splits the figure window into small subfigures and makes the pth subfigure active.

Lab Task
Plot the functions that were plotted in last lab task in the following two ways.

1. In two different figures


2. In a figure but separately using subplot.

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 22


Plotting the Continuous Time and Discrete Time Functions
A discrete time function is a function of the form In this
case the appropriate command for plotting the function is ‘stem(n,f)’

Lab Task
Plot the discrete function𝑓[𝑛] = 𝑛2, 𝑤ℎ𝑒𝑟𝑒 − 2 ≤ 𝑛 ≤ 2.

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 23


n = -3:3
f= n.^2
stem(n,f)
xlabel('Time Axis')
ylabel('Amplitude')
title('Graph of f(n)')

Modify the above lab task to create figure like below.

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

% Program to understand piecewise functions plotting

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')

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 25


Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 26
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

Instructor Signature: Date:

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 27


LAB # 2: To Describe the Periodic and Aperiodic Continuous and Discrete Time
Signals Using Elementary Signals in MATLAB

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

Part I- Characterization of Signal by Variable Type

Continuous Time Signals


A signal is called continuous-time (or analog) signals if the independent (time) is defined in continuous interval.
For signals, time domain of signal is continuous interval of the axis. In other words, for continuous-time
signals the independent variable is continuous. Moreover, the dependent value that usually denotes the
amplitude of the signal is also continuous variable. An example of such a signal is speech as a function of time.
An analog Signal is expressed by a function 𝑥(𝑡) , where takes real values.

Discrete Time Signals


A signal is called a discrete-time signal if the independent variable (time) is defined in a discrete interval (e.g.,
the set of integer number), while the dependent variable is defined in a continuous set of values. In the
following example, the discrete-time signal 𝑦[𝑛] = cos[𝑛] is plotted. Note that when referring to discrete
time the variable n is typically used to represent the time.
A discrete time signal x[n] is usually obtained by sampling a continuous-time signal 𝑥(𝑡) at a constant rate.
Suppose Ts is the sampling period, that is every Ts we sample the value of 𝑥(𝑡) . Suppose also that n , i.e.
The sequence of the sample is derived from the continuous time signal 𝑥(𝑡).

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 .

Part II - Basic Continuous Time Signals


We present the basic continuous Time Signals along with the way they are implemented and plotted in
MATLAB.

Sinusoidal Signal
The first basic category presented is that of sinusoidal signal. This type of signal is of the form

Where

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 28


Sinusoidal signals are periodic signals with fundamental period given by
.
Finally, a useful quantity is the frequency f given in Hertz. Frequency is defined by

Complex Exponential Signals


Another signal highly associated with sinusoidal signal is the complex exponential signal. is also
2𝜋
periodic with fundamental period given by 𝑇 = 𝜔 . According to derived straightforward from Euler’s Formula

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

Unit Step Function


Another basic signal is unit step function u(t). The unit step function is given by
1 𝑛 ≥0
𝑢[𝑛] = {
0 𝑛 <0
i.e. it is not defined at t=0. In the following example three different methods of defining and plotting the unit
step function are presented. `

The MATLAB command that generates the unit step function is the command heaviside(t).

Unit Impulse or Dirac Delta Function


The Dirac delta 𝛿(𝑡), strictly speaking, is not a function but is defined through its properties. The main property
is

Where 𝑓(. ) is an arbitrary function. Suppose that 𝑓(𝑡) = 1, t . Then

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

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 29


1 𝑡 =0
𝛿(𝑡) = {
0 𝑡 ≠0

Part III – Basic Discrete Time Signals


Now we will discuss the discrete time signals. Discrete time signals are the sequences. A sequence
consists of infinite (real or complex) elements or samples. DT signals are treated in the
same way as the continuous time signals. However there are two main differences.

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.

Unit Impulse Sequence


The unit impulse sequence is the counter part of the dirac delta function when dealing with discrete time
signals. It is also known as Kronecker delta. The mathematical expression of the 𝛿[𝑛] is :
1 𝑛 =0
𝛿[𝑛] = {
0 𝑛 ≠0
In general, the unit impulse sequence is given by,
1 𝑛 = 𝑛0
𝛿[𝑛 − 𝑛0] = {0 𝑛 ≠ 𝑛0

Unit Step Sequence


The unit step sequence is the counterpart of the unit step function when dealing with discrete time signals.
The mathematical expression is
1 𝑛 ≥0
𝑢[𝑛] = {
0 𝑛 <0
In general case, the unit step sequence is given by
1 𝑛 ≥ 𝑛0
𝑢[𝑛 − 𝑛0 ] = {
0 𝑛 < 𝑛0
The command of the heaviside is not applicable to the unit step sequence.

Real Exponential Sequence


The mathematical expression of a real valued exponential sequence is the sequence
is ascending if |a|>1, and descending if .

Sinusoidal Sequence
The sinusoidal sequence is defined by the expression of the form

Where
𝐴 = 𝐴𝑚𝑝𝑙𝑖𝑡𝑢𝑑𝑒
𝜑 = 𝑝ℎ𝑎𝑠𝑒
𝜔 = 𝑓𝑟𝑒𝑞𝑢𝑒𝑛𝑐𝑦

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 30


Pre Lab Tasks
(Attach extra A4 White page if needed)

1. Define and plot the signal 𝑥(𝑡) = cos(𝜋𝑡).


2. Define and plot the real and the imaginary part of the signal 𝑦(𝑡) = 𝑒3𝑗𝑡 , in the time of two periods.
3. Plot in the time interval , the following signals:
a.
b.
c.
d.
e.
f.
g.
h.

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

Plot the rectangular pulse function for the

Lab Tasks
Lab Task
Plot the continuous time signal .
Your plotted signal should look like as shown in the figure

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 31


Lab Task
Plot the discrete time signal

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 32


Lab Task
Modify the above lab tasks to plot the CT and DT signals together.

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 33


0.8

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

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 34


Lab Task
Plot the signal in four periods.

Lab Task
Plot the following two signals together in the same plot.

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 35


Lab Task
Plot the Signal in the time interval -T .
Where

, and

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 36


Lab Task
𝑗𝜋𝑡+𝜋
Plot the real and imaginary parts of signal 𝑦(𝑡) = 𝑒 3 in the time of one period.
2𝜋 2𝜋
First of all find the period of the signal. 𝑇 = = =2
𝜔 𝜋

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 37


Lab Task
Implement the unit step function.

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 38


Plot the unit step function for 𝑡0 = 2.

Lab Task
Plot the unit impulse function.

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 39


Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 40
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

Instructor Signature: Date:

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 41


LAB# 3: To Explain the Properties of Different Signal Types Using Signal
Operations in MATLAB

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

Part I-Properties of Continuous Time Signals


Continuous Time Periodic Signals
A continuous-time signal 𝑥(𝑡) is periodic if there is a positive number T such that

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 𝑥(𝑡).
𝜔 𝜔 𝜔

Sum of Continuous Time Periodic Signals


Suppose that 𝑥1(𝑡) 𝑎𝑛𝑑 𝑥2(𝑡) are periodic signals with periods 𝑇1 𝑎𝑛𝑑 𝑇2 , respectively. In this chapter, the
condition that must be fulfilled in order for the signal𝑥(𝑡) = 𝑥1(𝑡) 𝑎𝑛𝑑 𝑥2(𝑡) to be also periodic is given.
Moreover, the period of 𝑥(𝑡) is computed. Since𝑥1(𝑡) 𝑎𝑛𝑑 𝑥2(𝑡) are periodic, we get

𝑥1(𝑡) = (𝑡 + 𝑚𝑇1) and 𝑥2(𝑡) = (𝑡 + 𝑘𝑇2) , 𝑘 ∈ 𝑍

Thus, 𝑥(𝑡) = 𝑥1(𝑡) + 𝑥2(𝑡) = 𝑥1(𝑡 + 𝑚𝑇1) + 𝑥2(𝑡 + 𝑘𝑇2), 𝑘 ∈ 𝑍

Suppose that x(t) is indeed periodic with period T. Then, the following relationship holds:
𝑥(𝑡) = 𝑥(𝑡 + 𝑇) = 𝑥1(𝑡 + 𝑇) + 𝑥2(𝑡 + 𝑇)

Combining the equations we yields,


𝑥1(𝑡 + 𝑇) + 𝑥2(𝑡 + 𝑇) = 𝑥1(𝑡 + 𝑚𝑇1) + 𝑥2(𝑡 + 𝑘𝑇2)

Equation is valid if

𝑚𝑇1 = 𝑘𝑇2 = 𝑇 𝑤ℎ𝑒𝑟𝑒 𝑚, 𝑘 ∈ 𝑍

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 42


if are prime numbers, then the period of the signal𝑥1(𝑡) 𝑎𝑛𝑑 𝑥2(𝑡) is computed directly according
to relation defined in above equation.

Discrete Time Periodic Signals


A discrete-time signal is periodic if there is a positive integer number N such that

A discrete-time signal x[n] is periodic if there are integer positive numbers such that

Continuous Time and Discrete Time Casual Signal


A signal 𝑥(𝑡) 𝑜𝑟 𝑥[𝑛] is casual if it is zero for all negative values of time, i.e.,𝑥 (𝑡) = 0, 𝑡 < 0. Non-casual
signals are signals that have non zero values in both positive and negative time. Finally, a signal that is zero for
all positive time is called anti casual.

Sum of Periodic Discrete-Time Periodic Signals


The sum z[n] = x[n] + y[n] of periodic signals x[n] with period N1, and y[n] with period N2 is periodic if the ratio
of periods of the summands is rational—that is, Here p and q are integers not divisible by each other
If so, the period of is

Even and Odd Signal / Sequence


A signal 𝑥(𝑡) is even (or has even symmetry or is an even function of t) if 𝑥(−𝑡) = 𝑥(𝑡), −∞ < 𝑡 < ∞ and the
same hold for the sequence 𝑥[𝑛].

A signal 𝑥(𝑡) is odd (or has odd symmetry or is an odd function of t) if 𝑥(−𝑡) = −𝑥(𝑡), −∞ < 𝑡 < ∞ and the
same hold for the sequence 𝑥[𝑛].

Energy and Power Signals/ Sequence


An important classification of signals is between (finite) energy and (finite) power signals. The Energy 𝐸𝑥 of a
continuous time signal 𝑥(𝑡) is computed according to

Where |𝑥(𝑡)| is the absolute value of 𝑥(𝑡). A signal is an energy signal if its energy is definite,
i.e.,0 ≤ 𝐸𝑥 < ∞ .

The Power 𝑃𝑥 of a signal 𝑥(𝑡) is given by

If 𝑥(𝑡) is periodic, the power is computed from the relationship.


Likewise the continuous time signals, discrete time signals can also be classified between (finite) energy and
(finite) power signals. The Energy 𝐸𝑥 of a discrete time signal 𝑥[𝑛] is computed according to

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 43


Where |𝑥(𝑡)| is the absolute value of 𝑥[𝑛]. A signal 𝑥[𝑛] is an energy signal if its energy is definite,
i.e, 0 ≤ 𝐸𝑥 < ∞ .

The Power of a signal is given by

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.

Part II- Signal Transformations


Transformations of the time Variable for Continuous-Time Signals
In many cases, there are signals related to each other with operations performed on the independent
variable, namely, the time. In this section, we examine the basic operations that are performed on the
independent variable.

Time Reversal or Reflection


The first operation discussed is the signal’s reflection. A signal is a reflection or a reflected version of
about the vertical axis if .

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.

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 44


Time Shifting
A third operation performed on time is one of time shifting. A signal 𝑦(𝑡) is a time-shifted version of 𝑥(𝑡) if
(𝑡) = 𝑥(𝑡 − 𝑡0) , where 𝑡0 is the time shift. If 𝑡0 > 0, the signal 𝑦(𝑡) = 𝑥(𝑡 − 𝑡0) is shifted by 𝑡0 units to the
right (i.e., toward +∞ ); while if 𝑡0 < 0, the signal 𝑦(𝑡) = 𝑥(𝑡 − 𝑡0) is shifted by 𝑡0 units to the left. The time
shifting is implemented in MATLAB in an opposite way to what may be expected. More specifically, in order
to plot the signal 𝑥(𝑡 − 𝑡0) the corresponding MATLAB statement is 𝑝𝑙𝑜𝑡(𝑡 + 𝑡0, 𝑥).

Pre Lab Tasks


(Attach extra A4 White page if needed)

1. Consider the signal Plot


a. The signal 𝑥(𝑡).
b. Then even decomposition 𝑥𝑒(𝑡) of 𝑥(𝑡).
c. The odd decomposition 𝑥𝑜(𝑡) of 𝑥(𝑡).
d. The signal 𝑦(𝑡) = 𝑥𝑒(𝑡) + 𝑥𝑜(𝑡).
𝑡 0≤𝑡≤2
2. Suppose that 𝑥(𝑡) = { . Plot the signals 𝑥(𝑡), 𝑥(−𝑡), 𝑥(𝑡/2), 𝑥(2 + 4𝑡) and
4−𝑡 2≤𝑡≤4
𝑥(−2 − 4𝑡).

Lab Tasks
Lab Task
Verify that the signal 𝑥(𝑡) = sin(𝑡) is periodic.

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 45


Lab Task
Plot the signal 𝑥(𝑡) = cos(𝑡) + sin(3𝑡) in time of three periods.

Lab Task
Plot the causal, non-causal and anti-causal signal and sequence.

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 46


Lab Task
Verify that is periodic

Lab Task
Find that signal is periodic/ aperiodic.

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 47


Lab Task
Find out if the signals 𝑥(𝑡) = 𝑡2 and 𝑦(𝑡) = 𝑡3 are even or odd.

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.

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 48


Lab Task
Verify that 𝑥(𝑡) = 𝑢(𝑡) is a power-type signal while 𝑥(𝑡) = 𝑢(𝑡) − 𝑢(𝑡 − 1) is an energy-type signal.

Lab Task
Compute the energy and the power of the signal 𝑥(𝑡) = 2𝑐𝑜𝑠(𝜋𝑡) in one period time.

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 49


Lab Task
Compute the energy of the signal

Lab Task
Compute the energy of the signal 𝑥[𝑛] = cos[𝑛] , −𝑅𝑜𝑙𝑙 𝑁𝑢𝑚𝑏𝑒𝑟 ≤ 𝑛 ≤ 𝑅𝑜𝑙𝑙 𝑁𝑢𝑚𝑏𝑒𝑟

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 50


Lab Task
Suppose that Plot the signal

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.

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 51


Lab Task
The signal 𝑥(𝑡) = 𝑡𝑒−𝑡, −1 ≤ 𝑡 ≤ 3 is again considered. We will plot the signals ,
that is, a shifted version of 𝑥(𝑡) by two units to the right (here 𝑡0 = 2) and ,
that is, a shifted version of 𝑥(𝑡) by 3 units to the left (here 𝑡0 = −3.)

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 52


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

Instructor Signature: Date:

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 53


LAB # 4: To Show the Response of Different System Classifications Using I/O
Relationship in MATLAB
Objectives
After completing this lab, the student will be able to:

✓ 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.

Classification according to the number of inputs and outputs


The first criterion is the number of input signals that the system accepts and the member of output signals it
returns.

Signal-Input Signal –Output (SISO) System


This is the simpler category. A continuous time SISO system accepts a single input signal and returns a single
output signal. A SISO system is depicted in Figure 4.1. A typical input/output (i/o) relationship that describes
a SISO is a relationship of the form , where a is the time delay, is the input signal, and
is the response of the system to the input signal.

Figure 4.1: Block diagram representation of a continuous-time system

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 54


Multiple-input single-output (MISO)
MISO system accepts multiple inputs but returns a single output. For example, a MISO system is described by
an I/O relationship of the form . A MISO system is
illustrated in figure 4.3

Figure 4.2: Block diagram representation of a MISO system

Classification According to Input Signals


A second classification of system is related to the “nature” of the input and output signals. More specifically,
a continuous-time system is a system in which continuous-time input signals result in continuous-time output
signals. On the other hand, a discrete-time system is a system in which the system response to discrete-time
input signal(s) is discrete-time output signal(s). Furthermore, there is also hybrid system in which a continuous-
time input signal is transformed into a discrete-time output signal and vice versa. An analog to digital (A/D)
converted is an example of a hybrid system.

Deterministic and Stochastic Systems


A third classification of system is between stochastic and deterministic system. A system is deterministic if no
randomness is involved in the input and output signals. A nondeterministic system is called stochastic. A
stochastic system (unlike a deterministic one) does not always produce the same output for a given input.

Pre Lab Tasks


(Attach extra A4 White page if needed)

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)

2. A MIMO system is described by the i/o relationships and


.Compute and plot the system response to the input signals
, and for 0 ≤ 𝑡 ≤ 5

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𝑢(𝑡)

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 55


Lab Task
Suppose that a MISO system is described by the I/O relationship 𝑦(𝑡) = 𝑥1(𝑡) + 𝑥2(𝑡). 𝑥3(𝑡).
Compute and plot the system’s output if the input signal are given by 𝑥1(𝑡) = 𝑢(𝑡) − 𝑢(𝑡 − 3),
𝑥2(𝑡) = 𝑡𝑠𝑖𝑛(𝑡), 0 ≤ 𝑡 ≥ 4, and 𝑥3(𝑡) = 𝑡𝑐𝑜𝑠(𝑡), 0 ≤ 𝑡 ≤ 4.

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).

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 56


Lab Task
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(𝑡) = 𝑒2𝑡, 0 ≤ 𝑡 ≤ 5, 𝑥2(𝑡) =
𝑡𝑒𝑡, 0 ≤ 𝑡 ≤ 5, and 𝑥3(𝑡) = cos(𝑡),0 ≤ 𝑡 ≤ 5.

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
.

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 57


Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 58
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

Instructor Signature: Date:

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 59


LAB # 5: To Explain the Properties of the System Using I/O Relationship in
MATLAB
Objectives
After completing this lab, the student will be able to:

✓ 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.

Causal and Non-Causal Systems


A system is causal if the system output 𝑦(𝑡0) at time 𝑡 = 𝑡0 does not depend on values of the input 𝑥(𝑡)
for 𝑡 > 𝑡0. In other words, for any input signal 𝑥(𝑡), the corresponding output 𝑦(𝑡) depends only on the
present and past values of 𝑥(𝑡). So, if the input to a causal system is zero for 𝑡 < 𝑡0 the output of this
system is also zero for 𝑡 = 𝑡0. Correspondingly, a discrete-time system is causal if its output 𝑦[𝑛0] at
time 𝑛 = 𝑛0 depends only on the values of the input signal 𝑥[𝑛] for 𝑛 ≤ 𝑛0 . All natural system is causal.
However, in engineering there are many non causal systems. For example off-line data processing is a
non causal system.

Static (Memory Less) and Dynamic (With Memory) System


A system is static or memory less if for any input signal 𝑥(𝑡) or 𝑥[𝑛] the corresponding output 𝑦(𝑡) or 𝑦[𝑛]
depends only on the value of the input signal at the same time. A non-static system is called dynamic or
dynamical.

Linear and Non-Linear System


Let 𝑦(𝑡) denote the response of a system S to an input signal 𝑥(𝑡), that is, 𝑦(𝑡) = 𝑆{𝑥(𝑡)}. System S is a
linear if for any input signals 𝑥1(𝑡) and 𝑥2(𝑡) and any scalars 𝑎1 and 𝑎2 the following relationship holds:

𝑆{𝑎1𝑥1(𝑡) + 𝑎2𝑥2(𝑡)} = 𝑎1𝑆{𝑥1(𝑡)} + 𝑎2𝑆{𝑥2(𝑡)}

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(𝑡).

𝑆{𝑥1(𝑡) + 𝑥2(𝑡)} = 𝑆{𝑥1(𝑡)} + 𝑆{𝑥2(𝑡)}

While the homogeneity property implies that for any scalar a and any input signal 𝑥(𝑡),

𝑆{𝑎𝑥(𝑡)} = 𝑎𝑆{𝑥(𝑡)}

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 60


Time-Invariance
A system is time invariant, if a time shift in the input signal results in the same time shift in the output signal.
In other words, if 𝑦(𝑡) is the response of a time invariant system to an input signal 𝑥(𝑡), then the system
response to the input signal 𝑥(𝑡 − 𝑡0) is 𝑦(𝑡 − 𝑡0). The mathematical expression is

Equivalently, a discrete-time system is time or (more appropriately) shift invariant if,

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.

Pre lab Tasks


(Attach extra A4 White page if needed)
1. Find out if the system described by the I/O relationship is static or dynamic?
2. Determine if the system with I/O relation is linear and time invariant.
3. Determine if the discrete-time systems with I/O relationship is stable.

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.

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 61


Lab Task
Determine if the discrete-time system described by the I/O relationship 𝑦[𝑛] = 𝑥2 and are static or
dynamic. Use the input signal 𝑥[𝑛] = [0 1 2 3 4], −1 ≤ 𝑛 ≤ 3.

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.

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 62


Lab Task
Determine if the linearity property holds for the discrete-time system described by the I/O relationship 𝑦[𝑛] =
and 𝑦[𝑛] = 𝑛𝑥[𝑛]. Consider the input signal 𝑥1[𝑛] = 0.8𝑛, 0 ≤ 𝑛 ≤ 5 0 ≤ n ≤ 5 and 𝑥2[𝑛] = cos[𝑛],
0 ≤ 𝑛 ≤ 5.
The linearity property holds for a discrete-time system if

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 63


Lab Task
Suppose that the response of a system S to an input signal Determine if this system is
time invariant by using the input signal

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 64


Lab Task
Consider a system described by the I/O relationship 𝑦(𝑡) = 1 − 2𝑥(𝑡 − 1). Determine if this is a time invariant
system by using the input signal 𝑥(𝑡) = cos(𝑡) [𝑢(𝑡) − 𝑢(𝑡 − 10)].

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 65


Lab Task
Suppose that an input signal 𝑥(𝑡) = cos(2𝜋𝑡) is applied to two systems described by the I/O relationship
and . Determine if these two system as stable.

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

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 66


Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 67
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

Instructor Signature: Date:

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 68


LAB # 6: To Sketch the Response of Linear Time Invariant Systems by
Performing Convolution Using MATLAB
Objectives
After completing this lab, the student will be able to:

✓ 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

By alternation variables and t, becomes

The Command conv


The computational process followed in the previous lab is the analytical way of deriving the convolution
between two signals. In MATLAB, the command allows the direct computation of the convolution
between two signals.

De-convolution of Continuous-Time Signals


Suppose that the impulse response of a system ℎ(𝑡) and the output of a system 𝑦(𝑡) are available and we
want to compute the input signal 𝑥(𝑡) that was applied to the system in order to generate the output 𝑦(𝑡).

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 ℎ = 𝑑𝑒𝑐𝑜𝑛𝑣(𝑦, 𝑥).

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 69


Remarks
The commutatively property is not valid for the command; hence, the output signal must be the first
input argument of the command

Computation of Discrete-Time Convolution


The process that has to be followed to analytically derive the convolution sum is similar to the one followed in
the continuous-time case. First, the input and impulse response signals are plotted in the k-axis. Then one of
the two signals is reversed about the amplitude axis, and its reflection is shifted form by changing
appropriately the value of n. the output of the system is computed from the overlapping values of 𝑥[𝑛] and
ℎ[𝑛 − 𝑘] according to the convolution sum

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 [𝑎𝑥 + 𝑎ℎ, 𝑏𝑥 + 𝑏ℎ]

De-convolution of Discrete-Time Signals


Suppose that the impulse response of a system ℎ[𝑛] and the output of a system 𝑦[𝑛] are available and we
want to compute the input signal 𝑥[𝑛] that was applied to the system in order to generate the output 𝑦[𝑛].
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 ℎ = 𝑑𝑒𝑐𝑜𝑛𝑣(𝑦, 𝑥).

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.

Pre Lab Tasks


(Attach extra A4 White page if needed)

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].

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 70


5. Suppose that a discrete-time system is described by the impulse response ℎ(𝑡) = 0.8𝑡, 0 ≤ 𝑡 ≤ 10.
Without using the command, compute and plot the response of the system to the input signal.

Lab Tasks
Lab Task
A linear time-invariant system is described by the impulse response

Calculate the response of the system to the input signal

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 71


Lab Task
We will consider the same signals used in the previous example. Therefore, the problem is to compute the
impulse response ℎ(𝑡) of a system when the response of the system to the input 𝑥(𝑡) is the signal 𝑦(𝑡), which
is depicted in the previous figure.

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

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 72


Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 73
Lab Task
Suppose that the impulse response of a system is
𝑛, −5 < 𝑛 ≤ 5
ℎ[𝑛] = {
0, 𝑒𝑙𝑠𝑒𝑤ℎ𝑒𝑟𝑒

Without using command compute the response of the system to the input signal
1, 0≤𝑛≤ 4
𝑥[𝑛 ]= {
0, 𝑒𝑙𝑠𝑒𝑤ℎ𝑒𝑟𝑒

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 74


Lab Task
Write a function that computes and plots the convolution of two sequences. The function must accept as
arguments the two signals and the time intervals in which the sequence are defined. Execute your function for

Lab Task
Compute the impulse response of system for which you have computed the system response in the above task
and verify the answer.

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 75


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

Instructor Signature: Date:

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 76


LAB # 7: To Sketch the Line Spectrum of Periodic Signals Using Properties of
Fourier Series Coefficients in MATLAB

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:

And the complex exponential signal:

Where is called the fundamental angular frequency.

Complex Exponential Fourier series Representation


The complex exponential Fourier series representation of a periodic signal 𝑥(𝑡) with fundamental period 𝑇0 is
given by:

Where 𝑎𝑘 are known as the complex Fourier coefficient is given by:

Plotting the Line Spectra


The graph of magnitudes versus frequency is known as magnitude spectrum, while the graph of the
angles of 𝑎𝑘 versus frequency is known as phase spectrum. They magnitude spectrum and phase spectrum
are collectively known as “Line Spectra”.

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 77


Trigonometric Fourier series Representation
The trigonometric Fourier series representation of a periodic signal 𝑥(𝑡) with fundamental period 𝑇0is given by:

Where 𝑎𝑘, 𝑏𝑘 are Fourier coefficients given by:

Properties of Fourier series


The Fourier series coefficients derived through the analysis equation determine completely a periodic signal 𝑥(𝑡).
Hence, one can say that the complex exponential coefficients 𝑎𝑘 and the signal 𝑥(𝑡) are Fourier series pair. This
relationship is denoted by 𝑥(𝑡) ↔ 𝑎𝑘. Some properties of Fourier series are presented in this section and MATLAB
programmers verify them.
Suppose that the complex exponential Fourier series coefficients of the periodic signal 𝑥(𝑡) and 𝑦(𝑡) are denoted
by 𝑎𝑘 and 𝑏𝑘 respectively, or in other words 𝑥(𝑡)↔𝑎𝑘 and 𝑦(𝑡)↔𝑏𝑘. Moreover let z1 and z2 denote two complex
numbers. Then,

Time Shifting
A shift in time of the periodic signal results on a phase change of the Fourier series coefficients. So if

The exact relationship is:

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,

Where ‘ * ’ denotes (discrete time) convolution.

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,

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 78


Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 79
Pre Lab Tasks
1. The periodic signal is defined in one period as 6. Plot the approximate
signals in 4 periods in time using 81 terms of the complex exponential and trigonometric forms of
Fourier series. For comparison reasons, plot the original signal over the same time interval.
2. The periodic signal in one period is given by :

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:

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 80


Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 81
Lab Task
The line spectra of the above example are computed below. The line spectra are plotted for and
.

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.

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 82


Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 83
Lab Task
To verify the linearity property, we consider the periodic signals 𝑥1(𝑡) = cos(𝑡) , 𝑥2(𝑡) = sin(2𝑡) and the
scalars 𝑧1 = 3 + 2𝑖 𝑎𝑛𝑑 𝑧2 = 2.

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).

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 84


Lab Task
In order to validate the time reversal property we consider the periodic signal that in one period is given
by 𝑥(𝑡) = 𝑡𝑐𝑜𝑠(𝑡), 0 ≤ 𝑡 ≤ 2𝜋.

Lab Task
To verify signal multiplication property we consider the signals 𝑥(𝑡) = 𝑐𝑜𝑠(𝑡) and 𝑦(𝑡) = 𝑠𝑖𝑛(𝑡).

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 85


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

Instructor Signature: Date:

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 86


LAB # 8: To Reproduce the Continuous Time Fourier Transform (CTFT) Using
MATLAB Functions

Objectives
After completing this lab, the student will be able to:
✓ Trace the output response of CTFT in MATLAB.

Pre Lab

Introduction to Fourier Transform


Mathematical Definition
As stated that, the Fourier transform expresses a signal (or function) in the (cyclic) frequency domain;
that is, the signal is described by a function 𝑋(𝜔). The Fourier transform is denoted by the symbol ; that
is one can write

In other words, the Fourier transform of a signal 𝑥(𝑡) is a signal 𝑋(𝜔). An alternative way of writing is

The mathematical expression of Fourier transform 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

The mathematical expression of the inverse Fourier transform is

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.

The Command fourier and ifourier


The computation of the integral is not always a trivial matter. However, in MATLAB ® there is a possibility to
compute is directly the Fourier transform 𝑋(𝜔) of a signal 𝑥(𝑡) by using command fourier. Correspondingly,

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 87


the inverse Fourier transform is computed by using the command ifourier. Before executing these two
commands, time and frequency must be declared as symbolic variables. Symbolic variable is declared by
using the command syms.

Fourier Transform Pairs


In this section, the most common Fourier transform pairs are represented. The computation of the Fourier
and inverse Fourier transform require the computation of the integrals and sometime can be quite hard. This
is the reason that already computed Fourier transform pairs are used to compute the Fourier or the inverse
Fourier transform of a function. Thus, the computational procedure is to express a complicated function of
interest in term of function with known Fourier (or inverse Fourier) transform and then based on the
properties of Fourier transform to compute the Fourier transform of the complicated function. In the following
table the common pairs are given below as:

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 88


Properties of Fourier Transform
In this section, we present the main properties of the Fourier transform. Each property is verified by an
appropriate example.

Linearity
If and then for any scalar and the following property stands:

Time Shifting
If 𝑋(𝜔) = 𝐹{𝑥(𝑡)} then for any

Frequency Shifting
If then for any ,

Scaling in Time and Frequency


If then for any scalar

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

Differentiation in Time and Frequency


If , then

Integration
If , then

Duality
If , then

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 89


Pre Lab Task
(Attach extra A4 White page if needed)

1. Compute and plot the Fourier transform of the following signals:

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 .

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 90


Lab Task
Compute the Fourier transform (or spectra) of the signal and compare with result of previous example.

Lab Task
Plot the Fourier transform of the continuous-time signal𝑥(𝑡) =

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 91


Lab Task
Suppose that a signal 𝑥(𝑡) is given by 𝑥(𝑡) = 𝑡𝑒−3𝑡. Compute the Fourier transform 𝑋(𝜔) of signal 𝑥(𝑡) and
plot for−20 ≤ 𝜔 ≤ 20 𝑟𝑎𝑑/𝑠𝑒𝑐:

a) The magnitude of 𝑋(𝜔)


b) The angle of 𝑋(𝜔)
c) The real part of 𝑋(𝜔)
d) The imaginary par of 𝑋(𝜔)

Lab Task
Compute the convolution between the signals and .

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 92


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

Instructor Signature: Date:

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 93


LAB # 9: To Reproduce the Discrete Time Fourier Transform (DTFT) Using
MATLAB Functions

Objectives
After completing this lab, the student will be able to:
✓ Trace the output response of DTFT in MATLAB.

Pre- Lab

Discrete Time Fourier Transform (DTFT)


The Discrete Time Fourier Transform (DTFT) or simply the Fourier Transform of a discrete time sequence x[n]
is a representation of the sequence in terms of complex exponential sequence , where w is real
frequency variable.

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.

The DTFT of a sequence is defined by following.

In general 𝑋(𝑒𝑗𝜔) is complex function of the real variable w and can be written in the rectangular form as

𝑋(𝑒𝑗𝜔) can alternately be expressed in polar 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

called principal value.

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

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 94


For all values of w and this is a sufficient condition for the existence of DTFT, 𝑋(𝑒𝑗𝜔) of a sequence 𝑥[𝑛] .

Linear Convolution using DTFT


An important property of DTFT is given by convolution theorem, which states that DTFT of a sequence 𝑦[𝑛]
generated by linear convolution of two sequence, 𝑔[𝑛] and ℎ[𝑛] is simply given by the product of their
respective DTFTs, 𝐺(𝑒𝑗𝜔) & 𝐻(𝑒𝑗𝜔). This implies that the linear convolution 𝑦[𝑛] of the two sequences,
𝑔[𝑛] and ℎ[𝑛] can be implemented by computing first their DTFTs 𝐺(𝑒𝑗𝜔) & 𝐻(𝑒𝑗𝜔), forming the product
𝑌(𝑒𝑗𝜔) = 𝐺(𝑒𝑗𝜔)𝐻(𝑒𝑗𝜔) and then computing the inverse DTFT.

Pre Lab Tasks

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.

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 95


Lab Task
Verify the flowing properties of DTFT. (a) Linearity (b) Time Shifting (c) Frequency Shifting (d) Integration and
Differentiation (e) Convolution (f) Modulation (g) Parseval Theorem

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 96


Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 97
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

Instructor Signature: Date:

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 98


LAB # 10: To Show the Response of Continuous Time Signals Using Laplace
Transform in MATLAB

Objectives
After completing this lab, the student will be able to:
✓ Explain the output of Laplace Transform using MATLAB.

Pre Lab

Laplace and Inverse Laplace Transform


Mathematical Definition
A continuous-time signal described in the time domain is a signal given by a function 𝑓(𝑡). As previously
mentioned, the Laplace transform expresses a signal in the complex frequency domain s (or s domain); that is,
a signal is described by a function 𝐹(𝑠) Laplace transform is denoted by the symbol 𝐿{. }; that is, one can write
𝐹(𝑠) = 𝐿{𝑓(𝑡)}
In other words, the Laplace transform of a function 𝑓(𝑡) is a function 𝐹(𝑠). An alternative way of writing is
𝐿
𝑓(𝑡) → 𝐹(𝑠)
There are two available forms of Laplace transform. The first is the two-sided (or bilateral) Laplace transform
where the Laplace transforms F(s) of a function is given by:

.
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

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 99


Command Laplace and ilaplace

Region of Convergence

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 100
FIGURE 10.1: Region of convergence of the Laplace transformof

Laplace Transform Pairs


In this section, the most common Laplace transform pairs are illustrated. The computation of Laplace
transform or the inverse Laplace transform requires the computation of the integrals and it can be quite hard.
This is the reason that already computed Laplace transform pairs are used to compute the Laplace transform
or the inverse Laplace transform of a function. Thus, the computational procedure is to express a complicated
function of interest in terms of function with known Laplace(or inverse Laplace) transform, and then based on
the properties of Laplace transform to compute the Laplace (or inverse Laplace) transform of the complicated
function. In the table below, the most common Laplace transform pairs are given. The illustrated pairs are
confirmed by using the commands laplace and ilplace. Recall that command laplace computes the unilateral
Laplace transform ( ). Thus, the unit step function (implemented in MATLAB with the command heaviside)
can be omitted.

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

𝑅 = [ 𝑟1, 𝑟2, … , 𝑟𝑛]

𝑃 = [𝑝1, 𝑝2, … , 𝑝𝑛]

K is the residue of the division of the two polynomials. K is null when 𝑚 < 𝑛.

Pre Lab Task


(Please attach extra A4 White page if needed)

1. Compute the Laplace Transform of the signals:


a.
b.
c.
2. Compute the inverse Laplace transform of the signal:

3. Express in partial fraction form the signal:

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

Instructor Signature: Date:

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

Laplace Transform Properties and Theorems


In this section, we present the main properties of the Laplace transform. Each property is verified by an
appropriate example

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))

Complex Frequency Shifting


If 𝑋(𝑠) = 𝐿{𝑥(𝑡)𝑢(𝑡)} then for any 𝑠0,

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])

Pre Lab Task


(Please attach extra A4 White page if needed)

1. Compute the convolution between the signals 𝑋1(𝑠) = 1 and 𝑋2(𝑠) = 2 .


(𝑠+1)2 (𝑠+1)3

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

Instructor Signature: Date:

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

Z-Transform and Inverse Z-Transform


Mathematical Definition
As Laplace transformation is a more general transform as compared to Fourier Transform for continuous-time
signals, z-Transform is a more general transform than discrete-time Fourier Transform when dealing with
discrete-time signal. A discrete-time signal is defined in the discrete time domain n; that is, it is given by a
function . Z-Transform is denoted by the symbol and expresses a signal in z-domain, i.e., the
signal is given by a function 𝐹(𝑧). The mathematical expression is

𝐹(𝑧) = 𝑍{𝑓[𝑛]}

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{𝐹(𝑧)}

The mathematical expression of the inverse z-transform is

The z-transform of a sequence is easily computed.

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.

Pre Lab Task


1. Compute the z-transform of the signal 𝑥[𝑛] = 𝑢[𝑛] + 𝑛𝑢[𝑛] + 𝑛2𝑢[𝑛].
2. Compute the z-transform of the signals 𝑥[𝑛] = 𝑢[𝑛] and 𝑥[𝑛] = 𝑢[𝑛 − 1].
3. Express in partial fraction form the signal:

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

a. When 𝑋(𝑧) is in the rational form.


b. When 𝑋(𝑧) is in partial fraction form.

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

Instructor Signature: Date:

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

Z-Transform Properties and Theorems


In this section, the main properties of the z-transform are introduced and verified through appropriate
examples.

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 =

(4*z)/(z - 2) + (3*z*(z + 1))/(z - 1)^3

Right =

(4*z)/(z - 2) + (3*z*(z + 1))/(z - 1)^3

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 𝑚,

% x[n] = 0.8n ,-3 ? n ? 3


n=-3:3;
x=0.8.^n;
xminus1=x(3);
xminus2=x(2);
xminus3=x(1);

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

If 𝑋(𝑧) = 𝑍{𝑥[𝑛]}, then for any positive integer ,

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))

Scaling in the z-Domain


If 𝑋(𝑧) = 𝑍{𝑥[𝑛]} then for any scalar a,

𝑍{𝑎−𝑛𝑥[𝑛]} = 𝑋(𝑎𝑧)

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 =

4*z^3 + 3*z^2 + 2*z + 1

Left =

2/z + 3/z^2 + 4/z^3 + 1

Differentiation in the z-domain


If 𝑋(𝑧) = 𝑍{𝑥[𝑛]} then
𝑑𝑋(𝑧)
𝑍{𝑛. 𝑥[𝑛]} = −𝑧
𝑑𝑧

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 =

(z^2*(z + 1))/(z - 1)^4

Right =

(z^2*(z + 1))/(z - 1)^4

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 124
Convolution in the time domain
If 𝑋1(𝑧) = 𝑍{𝑥1[𝑛]} and𝑋2(𝑧) = 𝑍{𝑥2[𝑛]}, then

𝑍{𝑥1[𝑛] ∗ 𝑥2[𝑛]} = 𝑋1(𝑧)𝑋2(𝑧)

Applying inverse z-transform to both sides yields

𝑥1[𝑛] ∗ 𝑥2[𝑛] = 𝑍−1{𝑋1(𝑧)𝑋2(𝑧)}

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

Instructor Signature: Date:

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.

IIR Filter Structures


The system function of an IIR filter is given by

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

Three discrete structures can be used to implement an IIR filter:

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

Figure: Direct form II 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.

Example: Given the following difference equation describing an IIR filter


𝑦[𝑛] − 𝑦[𝑛 − 1] + 0.9𝑦[𝑛 − 2] = 𝑥[𝑛] + 0.3𝑥[𝑛 − 1]
a. Calculate and plot the impulse response ℎ[𝑛] at 𝑛 = −20, … ,100.
b. Calculate and plot the unit step response 𝑢[𝑛] at 𝑛 = −20, … ,100.

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;

%%%%% Generating the impulse sequence


if((n0 < n1) | (n0 > n2) | (n1 >
n2))
error('arguments must satisfy n1 <= n0 <=n2')
end
n = [n1:n2];

%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)');

%%%% Generating the unit step sequence


if((n0 < n1)|(n0 > n2)|(n1 > n2))
error('arguments must satisfy n1 <= n0 <= n2')
end
n = [n1:n2];

%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.

FIR Filter Structures


A finite duration impulse response filter has a system function of the form
𝑀−1
𝐻(𝑧) = ∑𝑏𝑛𝑧−𝑛 = 𝑏0 + 𝑏1𝑧−1 + ⋯ + 𝑏𝑀−1𝑧−𝑀 0
Hence the impulse response ℎ[𝑛] is
𝑏𝑛 0≤𝑛≤ 𝑀−1
[ ]
ℎ𝑛 ={
0 𝑒𝑙𝑠𝑒

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.

We will consider the following four structures:

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 𝐻(𝑒𝑗𝑤).

Direct Form Implementation


The difference equation mentioned above is implemented as a tapped delay line since there are no feedback
paths. Let 𝑀 = 5 (i.e., a fourth-order FIR filter); then
𝑦[𝑛] = 𝑏0𝑥[𝑛] + 𝑏1𝑥[𝑛 − 1] + 𝑏2𝑥[𝑛 − 2] + 𝑏3𝑥[𝑛 − 3] + 𝑏4𝑥[𝑛 − 4]
The direct form structure is given in below figure. Note that since the denominator is equal to unity, there is
only one direct form structure.

Figure: Direct form FIR structure

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

Determine and draw the block diagrams of the following structures:


a. Direct form I
b. Direct form II
Compute the response of the system to
𝑥[𝑛] = 𝑢[𝑛], 0 ≤ 𝑛 ≤ 100

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

Instructor Signature: Date:

Umair Shafiq Khan CPE223 Signals and Systems Lab Manual 134

You might also like