Vous êtes sur la page 1sur 145

Signals And Systems Lab Manual EL-315

SIGNALS AND SYSTEMS LAB MANUAL


EL-315

School of Engineering

University of Management and


Technology
CII, Johar Town Lahore
http:/www.umt.edu.pk

1
Signals And Systems Lab Manual EL-315

SIGNALS AND SYSTEMS LAB MANUAL


EL-315

Muhammad Ilyas Khan


Assistant Professor

Asma Umar
Lab Engineer

SaimaShaheen
Lab Engineer

School of Engineering
University of Management and Technology
CII, Johar Town Lahore
http:/www.umt.edu.pk

2
Signals And Systems Lab Manual EL-315

University of Management & Technology


School of Science & Technology
Department of Electrical Engineering

EL-315 Signals & Systems Lab


List Of Experiments

Week Experiments Text Book Reading Topics

1 Introduction to MATLAB

2 Implementation of basic sequences and 1.4: Classification of Signals.


calculation of their energy and power. 1.6: Elementary Signals.
3 Generation of complex exponential, real 1.6: Elementary Signals.
exponential, sinusoidal and random signals
on Matlab
4 Implementation of signal addition, 1.5: Basic Operations on
multiplication, scaling, shifting, folding, Signals.
sample summation, even and odd synthesis
on Matlab
5 Calculation of impulse response and step 2.7-8 : Impulse Response of
response of Linear-Time-Invariant (LTI) LTI system ; Step Response of
system LTI system.
6 Simulation of Linear-Time-Invariant (LTI) system
2.7:Relations between LTI
Properties System properties.
7 Continuous time convolution 2.4-5: Convolution Integral
and its Evaluation.

8 Discrete time convolution 2.2-3: Convolution Sum an


Evaluation.
9 Fourier series, magnitude and 3.3-5: Fourier Representation
phase calculation on Matlab of Signals, Discrete Time
Fourier Series, Continuous
Time Fourier Series.
10 Fourier transform 3.6-7: Discrete Time Fourier
Transform, Continuous Time
Fourier Transform.

3
Signals And Systems Lab Manual EL-315

11 Time and frequency characterization of 3.8-16: Properties of Fourier


signals and systems Representation.
12 Comparison of continuous-time & discrete- 4.5: Sampling.
time Signals and Sampling and Signal
Reconstruction
13 Z-transform using residuez method, pole- 7.1-3: Introduction to Z
zero plot Transform, Properties of
region of Convergence for Z
Transform
14 Inverse z-transform on matlab 7.5: Inversion of Z Transform

Text Book: Signals & Systems by Simon Haykin and Barry Van Veen, 2 nd
Edition, John Wiley & Sons

4
Signals And Systems Lab Manual EL-315

LAB-1: Introduction to MATLAB

Roll #:_____________________________

OBJECTIVES:

 Be able to explain MATLAB as a computation and visualization tool in the study of


signals and system.
 Be able to explain MATLAB Variables, Arithmetic operations, Control flow statements,
Math Functions and Plotting in MATLAB.

MATLAB is a programming language and data visualization software package which is especially
effective in signal processing and system analysis.

Getting Help from Within MATLAB

If you know the name of a function which you would like to learn how to use, use the help.
>> help function name

This command displays a description of the function and generally also includes a list of
related Functions. If you cannot remember the name of the function, use the lookfor.
>>lookfor keyword

This command will display a list of functions that include the keyword in their
descriptions.
Other help commands that you may find useful are info what and which.

MATLAB Variables — Scalars, Vectors, and Matrices

MATLAB stores variables in the form of matrices which are M x N, where M is the number of
rows and N is the number of columns. All elements of a matrix can be real or complex numbers.

Real scalar >>x=5


Complex scalar >> x = 5+10j (or >> x = 5+10i)
Row vector >> x=[1 2 3]
Column vector >>x = [1; 2; 3]
3x3matrix >> x=[1 2 3;4 5 6;7 8 9]

5
Signals And Systems Lab Manual EL-315

Arithmetic Operations

There are four different arithmetic operators:


+ Addition
- Subtraction
* Multiplication
/ Division(for matrices it also means inversion)

There are also three other operators that operate on an element by element basis:
.* multiplication of two vectors, element by element
./ division of two vectors, element-wise
.^ raise all the elements of a vector to a power.

Example:-
>> X= [1,3,4]
>> Y= [4,5,6]
>> X+Y
Ans= __________

>> X*Y.
Ans= __________
>> X.*Y
Ans = ___________

Complex numbers :

MATLAB also supports complex numbers. The imaginary number is denoted with the i. or j..
>> z =3 + 4i
>>conj(z) =______________ % computes the conjugate of z
>>angle(z) =______________ % computes the phase of z
>>real(z) = ______________ % computes the real part of z
>>imag(z) = ______________ % computes the imaginary part of z
>>abs(z) = ______________ % computes the magnitude of z

Array Indexing

In MATLAB, all arrays (vectors) are indexed starting with 1, i.e., y(1) is the first element of the
array y. Note that the arrays are indexed using parenthesis (.) and not square brackets[.] as in
C/C++. To create an array having as elements the integers 1 through 6, just enter:

6
Signals And Systems Lab Manual EL-315

>> x=[1,2,3,4,5,6]

Alternatively, you can use the: notation,


>> x=1:6

The: notation above creates a vector starting from 1 to 6, in steps of 1. If you want to create a
vector from
1 to 6 in steps of say 2, then type:

>> x=1:2:6 = ____________________________


>>ii=2:4:17 = ___________________________
>>jj=20:-2:0 = _____________________________

Extracting or inserting numbers in a vector can be done very easily. To concatenate an array, you
can usethe []operator, as shown in the example below:
>> x=[1:3 4 6 100:110]

To access a subset of the array, try the following:


>>x(3:7) = __________________
>>length(x) = _______________% gives the size of the array or vector

Allocating memory

You can allocate memory for one-dimensional arrays (vectors) using the zeros command.
The following command allocates memory for a 100-dimensional array:
>> Y = zeros(100,1);
>>Y(30) = ______________

Similarly, you can allocate memory for two-dimensional arrays (matrices). The command >>
Y=zeros (4, 5) defines a 4 by 5matrix.
>> Y= ones (1, 5) = ____________________________________

Special characters and functions

Some common special characters used in MATLAB are:


Pi(pi=3.14...)

7
Signals And Systems Lab Manual EL-315

sqrt indicates square root e.g., sqrt(4)=2

^ indicates power (e.g., 3^ 2=9)

abs Absolute value | .| e.g., abs(-3)=3

NaN Not-a-number, obtained when comparing mathematically undefined operations, such as


0/0.

; Indicates the end of a row in a matrix. It is also used to suppress printing on the screen

% denotes a comment. Anything to the right of % is ignored by the MATLAB interpreter and is
considered as comments
. Denotes transpose of a vector or matrix. It is also used to define strings,
e.g., str1=’DSP’;

find - Finds indices of nonzero elements.

Control Flow

MATLAB has the following flow control constructs:


• if statements
• switch statements
• for loops
• while loops
• break statements

The if, for, switch and while statements need to terminate with an end statement.
Examples:

IF:
>> X = -3;
>> If X>0 str =’positive.’
elseif X==0 str = ‘equal. ‘
elseif X <0 str = ‘negative.’
else str= ‘error.’
end
Answer :-str = _______________________________
Do if X = 3
Answer :-str = _______________________________

8
Signals And Systems Lab Manual EL-315

WHILE:
>> X= -10 ;
>>while X < 0
X= X+1;
end

Value of X after execution of loop = _____________________________________

FOR loop:
>> Y= 0;
for X= 1:10
Y=Y+1;
end
Value of X after execution of loop =_________________________________

BREAK:
The break statement lets you exit early from a for or a while loop:
>> x=-10;
while x<0
x=x+2;
if x == -2
break;
end
end

Relational Operators
Symbol Meaning:
<= Lessthanequal
< Less than
>= Greater than equal
> Greater than
== Equal
~=Not equal

Logical Operators
Symbol Meaning:
& AND
| O
~ NOT

9
Signals And Systems Lab Manual EL-315

Math Functions

MATLAB comes with a large number of built-in functions that operate on matrices on an
element-by element basis. These include:

sin sine

cos cosine
tan tangent
exp exponential
lognatural logarithm
log10 common logarithm
sqrt square root
absabsolute value

Plotting

The simple 2D plotting commands include:


Plot Plot in linear coordinates as a continuous function
stem Plot in linear coordinates as discrete samples
loglog Logarithmic
bar Bar graph
polar Polar co ordinates
Example:-
X= 0 : 90;
Y = cos (x);
Plot (Y);
Plot(X);
Stem(X);

Draw your plots here.

10
Signals And Systems Lab Manual EL-315

Programming in MATLAB (M-files)

MATLAB programming is done using M-files, i.e., files that have the extension .m. These files are
created using
a text editor. To open the text editor, go to the File pull-down menu, choose New, then M-file.
After you type in the program, save it, and then call it from the command window to execute it.

Example:-

Say for instance that you want to write a program to compute the average (mean) of a vector x.
The program should take as input the vector x and return the average of the vector.

Steps:

1. You need to create a new file, called “average.m”. Open the open the text editor by going to
the File pull-down menu; choose New, then M-file. Type the following in empty text file.

function y=average(x)
L=length(x);
sum=0;
for i=1:L
sum=sum+x(i);
end
y=sum/L; % the average of x

Remarks:
y is the output of the function “average”

x is the input array to the function “average”

Average is the name of the function. It is best if it has the same name as the filename. MATLAB
files always need to have the extension .m2. From the Editor pull-down menu, go to File | Save,
and enter: average.m for the filename.

3. Go to the Command window to execute the program by typing:

>> x=1:100;
>> y=average(x)
ans =
50.5000

11
Signals And Systems Lab Manual EL-315

LAB Assignment

Write a MATLAB program that will add all the numbers corresponding to the even or odd (your
registration number) indices of an array. For instance, if the array x was x=[1, 3, 5, 10], and your
registration number is even ;
then it should return 13 (= 3 + 10). Use that program to find the sum of all integers from 1 to your
Registration number. Write your program so that it is flexible. That is, you should be able to
invoke your program from
the command window as follows:

>> y = addnumber(x)
Where x is the input vector, and y is the sum of all the numbers corresponding to the indices of x.

12
Signals And Systems Lab Manual EL-315

Observations/Comments/Explanation of Results:

Score of Student in this Lab: _________________________________________

Instructor’s Signatures with Date: _____________________________________

13
Signals And Systems Lab Manual EL-315

Questions:

1. How will you create a 3 by 3 matrix in Matlab?


2. How will you create a row vector in Matlab?
3. How will you create a column vector in Matlab?
4. Write command to compute multiplication of two vectors element by element.
5. Write command to compute conjugate of a complex number.
6. Write command to get the size of an array or vector.
7. Write command to compute magnitude and phase angle of a complex number.
8. Write command to compute real and imaginary part of a complex number.
9. Make an array of 5 by 6 matrix having all elements initialized to zero.
10. How will you plot a continuous function in Matlab?

14
Signals And Systems Lab Manual EL-315

LAB-2: Implementation of basic sequences and calculation of their


energy and power.
Roll #:_____________________________

OBJECTIVES:

 Be able to implement basic sequences on MATLAB.


 Be able to compute the power and energy of different signals in MATLAB environment.

INTRODUCTION

Signals are represented mathematically as functions of one or more independent variables. For
convenience, we generally refer to the independent variable as time. Signals are broadly
classified into analog and discrete signals.

An analog signal will be denoted by 𝑥𝑎 (𝑡) in which the variable𝑡 represents time in seconds.

A discrete signal will be denoted by𝑥(𝑛)in which the variable 𝑛is integer and represents
discrete instances in time. It is also represented as

𝒙(𝒏) = {𝒙(𝒏)} = {… . , 𝒙(−𝟏), 𝒙(𝟎), 𝒙(𝟏), … } (2-1)



Where the up-arrow indicates the sample at n=0. In MATLAB we can represent a finite–
duration sequence by a row vector of appropriate values. However, such a vector doesn’t have
any information about sample position n. Therefore a correct representation of 𝑥(𝑛) would
require two vectors, one each for "𝑥"and "𝑛".

BASIC SEQUENCES

UNIT SAMPLE SEQUENCE

𝟏, 𝒏=𝟎 (2-2)
𝜹[𝒏] = {
𝟎, 𝒏≠𝟎

15
Signals And Systems Lab Manual EL-315

We will see how we can use unit impulse (sample) signal as basic building blocks for the
construction and representation of other signals.

δ(n) 1

n
Figure2-1: Discrete-Unit sample (impulse)

Similarly unit sample can be expressed as the first difference of the unit step.

𝜹[𝒏] = 𝒖[𝒏] − 𝒖[𝒏 − 𝟏] (2-3)

Unit Impulse can be used to sample the value of the signal at n=0.

𝒙[𝒏]𝜹[𝒏] = 𝒙[𝟎]𝜹[𝒏] (2-4)

This sampling property plays an important role in signal reconstruction.

UNIT STEP SEQUENCE

𝟏, 𝒏≥𝟎 (2-5)
𝒖[𝒏] = {
𝟎, 𝒏<0

16
Signals And Systems Lab Manual EL-315

1
u (n)
.......
.
0 1 2 3 4 . . . n

Figure 2-2: Discrete unit step

There is a close relationship between the unit step and unit sample i.e. unit step is the running
sum of the unit sample.

𝑢[𝑛] = ∑ 𝛿[𝑛 − 𝑚] (2-6)


𝑚=0

TOTAL ENERGY OF THE SIGNAL:


If x[n] is our discrete time signal then its total energy will be

+∝

𝑬 ∝ = ∑|𝒙[𝒏]|𝟐 −∝≤ 𝒏 ≤ +∝ (2-7)


−∝

TOTAL POWER OF THE SIGNAL:


If x[n] is our discrete time signal then its total power will be

+𝑵
𝟏
𝑷 ∝ = 𝐥𝐢𝐦 ∑|𝒙[𝒏]|𝟐 − 𝑵 ≤ 𝒏 ≤ +𝑵 (2-8)
𝑵→∝ 𝟐𝑵 + 𝟏
−𝑵

16
Signals And Systems Lab Manual EL-315

LAB TASK
Note: make m-file, show function’s plot,xlabel,ylabel,hold, stem and observe the output and show to
the instructor, see MATLAB help.

UNIT IMPULSE IMPLEMENTATION

function [x,n]=impseq(n0,n1,n2)
%Generate x(n) = delta(n-n0); n1 ≤n≤n2
%---------------------------------------------------
%[x,n]=impseq(n0,n1,n2)
n=[n1:n2]; x= [(n-n0)== 0];

UNIT STEP IMPLEMENTATION

%Generating Unit Step Function


function [x,n] = stepseq(n0,n1,n2)
%Generate x(n) = u(n-n0); n1 ≤ n ≤n2
%---------------------------------------------------
%[x,n] = stepseq(n0,n1,n2)
n = [n1:n2]; x = [(n-n0) >= 0];

SIGNAL ENERGY IMPLEMENTATION

Where the superscript “*” denotes the operation of complex conjugation. The energy of a finite
duration sequence x(n) can be computed in MATLAB using

≫ 𝑬𝒙 = 𝒔𝒖𝒎(𝒙.∗ 𝒄𝒐𝒏𝒋(𝒙)); % 𝒇𝒐𝒓𝒄𝒐𝒎𝒑𝒍𝒆𝒙𝒔𝒆𝒒𝒖𝒆𝒏𝒄𝒆


≫ 𝑬𝒙 = 𝒔𝒖𝒎(𝒂𝒃𝒔(𝒙).^ 𝟐) % 𝒇𝒐𝒓𝒓𝒆𝒂𝒍𝒔𝒆𝒒𝒖𝒆𝒏𝒄𝒆;

SIGNAL POWER:

The average power of a periodic sequence with fundamental period N is given by


𝟏 𝑵−𝟏
𝑷𝒙 = ∑ |𝒙[𝒏]|𝟐
𝑵 𝟎

17
Signals And Systems Lab Manual EL-315

LAB ASSIGNMENT

Give a title to the graph, label the x-axis and the y-axis respectively. Give specific color lines to
the input and output for discrimination.(Hint see MATLAB “help plot”)

P.1

Generate and plot the samples of the following sequences using MATLAB. Also find energy
and power of these functions.

a. 𝑥1 (𝑛) = ∑10
𝑚=0(𝑚 + 1)[𝛿(𝑛 − 2𝑚) − 𝛿(𝑛 − 2𝑚 − 1)], 0 ≤ 𝑛 ≤ 25

b. 𝑥2 (𝑛) = 𝑛2 [𝑢(𝑛 + 5) − 𝑢(𝑛 − 6)] + 10𝛿(𝑛) + 20(0.5)𝑛 [𝑢(𝑛 − 4) − 𝑢(𝑛 − 10)] −

25 ≤ 𝑛 ≤ 25

Hint: See Matlab help for “stem” function and “for loop”

18
Signals And Systems Lab Manual EL-315

Observations/Comments/Explanation of Results:

Score of Student in this Lab: _________________________________________

Instructor’s Signatures with Date: _____________________________________

19
Signals And Systems Lab Manual EL-315

Questions:

1. What are signals?


2. What is the difference between analogue and discrete signal?
3. What is unit sample sequence?
4. What is unit step sequence?
5. What is the difference between unit sample and unit step sequence?
6. How will you calculate total energy of the signal?
7. How will you calculate total power of the signal?
8. How will you plot a continuous function in Matlab?
9. How will you plot a discrete signal in Matlab?
10. How will you label the x-axis and y-axis of the graph?

20
Signals And Systems Lab Manual EL-315

LAB-3: Generation of complex exponential, real exponential,


sinusoidal and random signals on Matlab.
Roll #:_____________________________

OBJECTIVES:

 To study different types of exponential signals and implement on MATLAB.


 To generate Random signals on MATLAB.

TYPES OF SEQUENCES

REAL VALUED EXPONENTIAL SEQUENCE

𝒙[𝒏] = 𝑪. 𝒆𝒂.𝒏 (3-1)

Where “𝐶“ and “𝑎” are real . There are basically two types of behavior.
 If a is positive
As “n” increases “𝑥[𝑛]” is growing exponential, a form that describes different physical
processes including chain reactions and complex chemical reactions.
 If a is negative
As “n” increases “𝑥[𝑛]” is decaying exponential, a form that describes the radioactive
decay, RC circuits and damped mechanical systems.

COMPLEX VALUED EXPONENTIAL SEQUENCE


Complex exponential signal is defined as :

𝒙[𝒏] = 𝒆(𝝈+𝒋𝒘𝟎)𝒏 (3-2)

As “ σ + jwo ” represents a complex number. Such functions are used to describe


population growth as a function of generation and total return on investment as a
function of day, month etc.

SINUSOIDAL SIGNALS
Sinusoidal signal is defined as:

𝒙[𝒏] = 𝒄𝒐𝒔(𝒘𝒐 𝒏 + 𝜽) (3-3)

21
Signals And Systems Lab Manual EL-315

RANDOM SINGALS
Many practical signals can’t be described by mathematical expressions like those
explained above. Such sequences are called the random (or stochastic) sequences and
characterized by probability density function or statistical moments.

In Matlab we can generate two types of random sequences.


 RAND(1,N)
It generates a length N random sequences whose elements are uniformly distributed
between [0,1].
 RANDN(1,N)
It generates a length N Gaussian random sequence with mean 0, and variance 1.

PERIODIC SEQUENCE
A sequence x[n] is periodic if

𝒙[𝒏] = 𝒙[𝒏 + 𝑵]; ∀𝒏 (3-4)

The smallest integer that satisfies the above relation is called the fundamental period.

EVEN AND ODD SIGNALS


"x[n]"is an even signal if it is identical to its time-reversal counterpart i.e.

𝒙[−𝒏] = 𝒙[𝒏] (3-5)

Similarly the signal is referred to as odd if

𝒙[−𝒏] = −𝒙[𝒏] (3-6)

22
Signals And Systems Lab Manual EL-315

LAB TASK

TASK1: REAL EXPONENTIAL SEQUENCE

𝑥1[𝑛] = (0.9)𝑛1 ; 0 ≤ 𝑛1 ≤ 10

n1 = [0:10];
x1 = (0.9).^n1;

 Plot “ x1(n1)”.
 Label x-axis and y-axis.
 Also give title to the graph.

TASK2: COMPLEX VALUED EXPONENTIAL SEQUENCE

 Plot the following sequence.

𝒙𝟐(𝒏) = 𝒆𝒙𝒑(𝟐 + 𝟑𝒊)𝒏𝟐; 𝟎 ≤ 𝒏𝟐 ≤ 𝟏𝟎

 Write its MATLAB code below


TASK3: SINUSOIDAL SEQUENCE

 Plot the following sequence.


𝝅
𝒙𝟑[𝒏] = 𝟑𝒄𝒐𝒔 (𝟎. 𝟏𝝅𝒏𝟑 + ) + 𝟐𝒔𝒊𝒏(𝟎. 𝟓𝝅𝒏𝟑), 𝟎 ≤ 𝒏𝟑 ≤ 𝟏𝟎
𝟑

TASK4: GENERATION OF COMPLEX VALUED EXPONENTIAL SEQUENCE

% Generation of a complex exponential sequence

clc;

c = -(1/12)+(pi/6)*i;

K = 2;

n = 0:40;

22
Signals And Systems Lab Manual EL-315

x = K*exp(c*n);

subplot(2,1,1);

stem(n,real(x));

xlabel(‘Time index n’);ylabel(‘Amplitude’);

title(’Real part’);

subplot(2,1,2);

stem(n,imag(x));

xlabel(‘Time index n’);ylabel(‘Amplitude’);

title(‘Imaginary part’);

TASK5: GENERATION OF REAL EXPONENTIAL SIGNAL

% Generation of a real exponential sequence

clc;

n = 0:35; a = 1.2; K = 0.2;

x = K*a.^+n;

stem(n,x);

xlabel(‘Time index n’);ylabel(‘Amplitude’);

TASK6: RANDOM SIGNAL GENERATION

n = [0:40];
x1 = rand(1,41);

stem(n,x1)

 Plot “ x1(n1)”.
 Label x-axis and y-axis.
 Also give title to the graph.

23
Signals And Systems Lab Manual EL-315

LAB ASSIGNMENT
P.1

Generate a random sequence of numbers upto 40 numbers of samples , called x1, then multiply
it with sin(n), and plot the result.

P.2

Generate the signal

𝒙(𝒏) = 𝒔𝒊𝒏(𝒏)𝒆(−𝟒𝝅𝒏) , 𝟎 ≤ 𝒏 ≤ 𝟏𝟎

Show the result graphically.

24
Signals And Systems Lab Manual EL-315

Observations/Comments/Explanation of Results:

Score of Student in this Lab: _________________________________________

Instructor’s Signatures with Date: _____________________________________

25
Signals And Systems Lab Manual EL-315

Questions:

1. Explain real valued exponential signals.


2. Explain complex valued exponential signals.
3. How will you generate random sequence of elements in matlab?
4. What is the difference between RAND(1,N) and RANDN(1,N) ?
5. What is periodic sequence?
6. Explain even and odd signals.
7. Explain “stem”.
8. Explain subplot.
9. How will you give title to the graph?
10. How will you label the x-axis and y-axis of the graph?

26
Signals And Systems Lab Manual EL-315

LAB-4: Implementation of signal addition, multiplication, scaling,


shifting, folding, sample summation, even and odd synthesis on
Matlab.
Roll #:_____________________________

OBJECTIVES:

 To study basic operations on signals and implement them on MATLAB.


 To compute even and odd parts of any signal.

BASIC OPERATIONS

TRANSFORMATION OF THE INDEPENDENT VARIABLE

TIME SHIFT

𝒙[𝒏 − 𝒏𝒐] (4-1)

A simple and very important example of transforming the independent variable of a


signal is a time shift. A time shift discrete time in it we have two signals𝒙[𝒏] and
𝒙[𝒏 − 𝒏𝒐]that is identical in shape, but are displaced or shifted relative to each other.
Eq.1 shows a time shifted discrete-time signal.

TIME REVERSAL

𝒙[−𝒏] (4-2)

A Time reversal signal x[−n] of x[n]is obtained by reflection about n=0 (i.e by reversing
the signal).

TIME SCALING

𝒙[𝜶𝒏] (4-3)

If we represent three signals x[n] , x[2n], x[3n] , that are related by linear scale changes
in the independent variable. If we think of the example x[n] as tape recording, then

27
Signals And Systems Lab Manual EL-315

x[2n] is that recording played at twice the speed, and x[n/2] is the recording played at
half-speed.

ADDITION AND MULTIPLICATION


Two discrete time signals x1[n]and x2[n] can be added up using standard addition if
both having the same order /or equal in length. Same rule holds for the multiplication in
standard form. But if both have unequal length then in this case we can also solve this
problem, using different strategy as in MATLAB there is no built-in function for solving
such problems so we have to make our own user defined function using function-file
code of such problems is given in the lab tasks. Using that code we can easily solve and
get the desired output.

PERIODIC SEQUENCE
A sequence x[n] is periodic if

𝒙[𝒏] = 𝒙[𝒏 + 𝑵]; ∀𝒏 (4-4)

The smallest integer that satisfies the above relation is called the fundamental period.

EVEN AND ODD SIGNALS


"x[n]"is an even signal if it is identical to its time-reversal counterpart i.e.

𝒙[−𝒏] = 𝒙[𝒏] (4-5)


Similarly the signal is referred to as odd if

𝒙[−𝒏] = −𝒙[𝒏] (4-6)

The even part can be evaluated by the formula given below

𝑬𝑽𝑬𝑵{𝒙[𝒏]} = 𝟏/𝟐[𝒙[𝒏] + 𝒙[−𝒏]] (4-7)

and for odd part the operatoin will be like

𝑶𝑫𝑫{𝒙[𝒏]} = 𝟏/𝟐[𝒙[𝒏] − 𝒙[−𝒏]] (4-8)

28
Signals And Systems Lab Manual EL-315

LAB TASK

TASK1: SIGNAL ADDITION.

Signal addition is implemented in MATLAB by using the arithmetic operator “+”. However, the
length of x1(n) and x2(n) must be same. If sequences are of unequal length, or if the sample
positions are different for equal length sequences; then we can’t directly use the operator “+”.
Implement below code for adding sequences of unequal length:

function [y,n] = sigadd(x1,n1,x2,n2)


%implements y(n)= x1(n)+x2(n)
%y[y,n]=sigadd(x1,n1,x2,n2)
%y=sum sequence over n, which includes n1 and n2
%x1=first sequence over n1
%x2= second sequence over n2 (n2 can be different from n1)
n=min(min(n1),min(n2)):max(max(n1),max(n2));
y1=zeros(1,length(n)); y2=y1;
y1(find((n>=min(n1))&(n<=max(n1))==1))=x1;
y2(find((n>=min(n2))&(n<=max(n2))==1))=x2;
y=y1+y2;

end
 Generate x1 and x2 given below
𝟏; 𝟏 ≤ 𝒏𝟏 ≤ 𝟗
𝒙𝟏 [𝒏𝟏] = {
𝟎; 𝒐𝒕𝒉𝒆𝒓𝒘𝒊𝒔𝒆
𝟏; 𝟑 ≤ 𝒏𝟐 ≤ 𝟏𝟎
𝒙𝟐 [𝒏𝟐] = {
𝟎; 𝒐𝒕𝒉𝒆𝒓𝒘𝒊𝒔𝒆
 Add x1[n] and x2[n] using function “sigadd”.

TASK 2: SIGNAL MULTIPLICATION.

Signal multiplication is implemented in MATLAB by using the array operator “.*”. However, the
length of x1(n) and x2(n) must be same. If sequences are of unequal length, or if the sample
positions are different for equal length sequences; then we can’t directly use the operator “.*”.
Implement below code for multiplying sequences of unequal length:

function [ y,n ] = sigmult(x1,n1,x2,n2 )


%implements y(n)= x1(n) *x2(n)
%-------------------------------------------
%y[y,n]=sigmult(x1,n1,x2,n2)
%y=product sequence over n, which includes n1 and n2
%x1=first sequence over n1
%x2= second sequence over n2 (n2 can be different from all)

29
Signals And Systems Lab Manual EL-315

%
n=min(min(n1),min(n2)):max(max(n1), max(n2)); % duration of y(n)
y1=zeros(1,length(n)); y2=y1; % initiallization
y1(find((n>=min(n1))&(n<=max(n1))==1))=x1;
y2(find((n>=min(n2))&(n<=max(n2))==1))=x2;
y=y1.*y2;
end

 Multiply both the signals defined in task4 x1 [n] and x2 [n] using the above function
“sigmult”

TASK 3: SCALING

In this operation each sample is multiplied by a scalar α.

𝛂{𝐱(𝐧)} = {𝛂𝐱(𝐧)} (4-9)

An arithmetic operator “*” is used to implement the scaling operation In MATLAB.

 Scale both the signals defined in task4 x1 [n] and x2 [n] such that we get 2x1 [n] ,5x2 [n].
 Show the results to the instructor.

TASK 4: SHIFTING

In this each sample of “x(n)” is shifted by an amount “k” to obtain a shifted sequence “y(n)”

𝒚(𝒏) = {𝒙(𝒏 − 𝒌)} (4-10)

function [y,n]= sigshift(x,m,n0)


%implements y(n)= x(n-n0)
%------------------------------------------
%[y,n] = sigshift (x,m,n0)
%
n=m+n0; y=x;

30
Signals And Systems Lab Manual EL-315

 Using function “sigshift”, shift x1 [n]task4 such that x1 [n − 4].

TASK 5: FOLDING

In this operation each sample of “x(n)” is flipped around n=0, to obtain a folded sequence
“y(n)”

𝒚(𝒏) = {𝒙(−𝒏)} (4-11)

In MATLAB this operation is implemented by “fliplr(x)” function for sample values and by
“flipper(n)” function for sample positions as shown in the “sigfold” function.

function [y,n]= sigfold(x,n)


%implements y(n)= x(-n)
%------------------------------------------
%[y,n] = sigfold(x,n)
%
Y= fliplr(x); n= -fliplr(n)

 Fold the signal obtained in the task5 [n] , and show to the instructor.

TASK 6: SAMPLE SUMMATION.

This operation differs from signal addition operation. It adds all sample values of x(n) between
x1(n) and x2(n).

𝐧𝟐 (4-12)
∑ 𝐱(𝐧) = 𝐱(𝐧𝟏) + ⋯ + 𝐱(𝐧𝟐)
𝐧=𝐧𝟏

ss = sum(x(n1:n2));

It is implemented by the sum(x(n1:n2)) function.

31
Signals And Systems Lab Manual EL-315

Using function “sum”, add samples of x1 [n] at 2,3,4,5 sample positions.

Using function “sum”, add samples of x1 [n] at 7,8,9,10 sample positions.

What result you have concluded from the functions “sigadd” and “sum”

TASK 7: SAMPLE PRODUCTS

This operation also differs from the signal multiplication operation. It multiplies all sample
values of x(n) between n1 and n2.
𝐧𝟐
(4-13)
∏ 𝐱(𝐧) = 𝐱(𝐧𝟏 ) × … × 𝐱(𝐧𝟐 )
𝐧𝟏

sp = prod(x(n1:n2));

 Using function “prod”, multiply samples of 𝒙𝟏 [𝒏] at 3,4,5 sample positions.


 Using function “prod”, multiply samples of 𝒙𝟏 [𝒏] at 8,9,10 sample positions.
 What result have you concluded from the functions “sigmult” and “prod”

TASK 8: EVEN AND ODD SYNTHESIS

function [xe, xo, m]= evenodd(x,n)


%Real signal decomposition into even and odd parts
%------------------------------------------------------------------
%[xe,xo,m]= evenodd(x,n)
%
m= -fliplr(n);
m1=min([m,n]); m2=max([m,n]); m= m1:m2;
nm=n(1)-m(1); n1= 1:length(n);
x1=zeros(1,length(m));
x1(n1+nm)= x; x=x1;
xe= 0.5*(x + fliplr(x));
xo= 0.5*(x- fliplr(x));

32
Signals And Systems Lab Manual EL-315

 Split the signal obtained in the task5 y[n] into its even and odd parts and show to the
instructor.
 Use stem function and plot ye,yo , and compare it to the y[n]

33
Signals And Systems Lab Manual EL-315

LAB ASSIGNMENT
P.1

Generate
𝒙(𝒏) = 𝒆(−𝒋𝟒𝝅𝒏) , 𝟎 ≤ 𝒏 ≤ 𝟏𝟎

𝒚(𝒏) = 𝒆(−𝟒𝒏) 𝒙(𝒏) + 𝒙(𝒏 − 𝟒)𝟎 ≤ 𝒏 ≤ 𝟏𝟎


Solve this by calling , signal add, signal shift functions, and show the result graphically.

P.2

Generate the complex-valued signal

𝒙(𝒏) = 𝒆(−𝟒𝝅𝒏) , 𝟎 ≤ 𝒏 ≤ 𝟏𝟎

Plot its even and odd part, andshow the graph in which all x(n), xe(n) and xo(n) are given using
subplot command.

33
Signals And Systems Lab Manual EL-315

Observations/Comments/Explanation of Results:

Score of Student in this Lab: _________________________________________

Instructor’s Signatures with Date: _____________________________________

34
Signals And Systems Lab Manual EL-315

Questions:

1. Explain Time Shifting.


2. Explain Time Reversal.
3. Explain Time Scaling.
4. Explain Folding.
5. How will you add and multiply two unequal length signals?
6. What is periodic sequence?
7. Explain even and odd signals.
8. Explain command ‘fliplr’.
9. How will you write 𝒙(𝒏) = 𝒆(−𝒋𝟒𝝅𝒏) , 𝟎 ≤ 𝒏 ≤ 𝟏𝟎 in Matlab.
10. Explain function ‘Sigfold’.

35
Signals And Systems Lab Manual EL-315

LAB-5: Calculation of impulse response and step response of Linear-


Time-Invariant (LTI) system

Roll #:_____________________________

OBJECTIVES:

 Be able to verify different properties of system on MATLAB.


 Be able to use command ‘FILTER’ to solve difference equations and to calculate impulse
and step response of LTI system on MATLAB.

INTRODUCTION

A system is a collection of elements or components that are organized for a common purpose.
Physical systems in the broad sense are an interconnection of components, devices or
subsystems.

CONTINUOUS-TIME SYSTEM

This is a system in which continuous-time signals are applied and result in continuous-time
output, such a system has x(t) and y(t) as input and output respectively.

DISCRETE-TIME SYSTEM

A discrete-time system is described as an operator 𝝉[ . ] that takes a sequence x(n) called


excitation and transforms it into another sequence y(n) called response. i.e.

𝒚(𝒏) = 𝝉[ 𝒙(𝒏)] (5-1)

CLASSIFICATION

LINEAR SYSTEM

A discrete system τ[ . ] is a linear if and only if L[ . ] satisfies the principle of superposition as


shown in Eq. 2.

𝑳[𝒂𝟏𝒙𝟏(𝒏) + 𝒂𝟐𝒙𝟐(𝒏)] = 𝒂𝟏𝑳[𝒙𝟏(𝒏)] + 𝒂𝟐𝑳[𝒙𝟐(𝒏)], ∀𝒂𝟏, 𝒂𝟐, 𝒙𝟏(𝒏), 𝒙𝟐(𝒏) (5-2)

36
Signals And Systems Lab Manual EL-315

The output y(t) of a linear system to an arbitrary input x(t) is given by

∝ ∝
(5-3)
𝒚(𝒏) = 𝑳[𝒙(𝒏)] = 𝑳[ ∑ 𝒙(𝒌)𝜹(𝒏 − 𝒌) = ∑ 𝒙(𝒌)𝑳(𝒏 − 𝒌)
𝒏=−∝ 𝒏=−∝

L(n − k)is called the response of linear system , called the impulse response.

LINEAR TIME-INVARIANT (LTI) SYSTEM

A linear system in which an input-output pair, x(n) and y(n) , is invariant to a shift n in time is
called a linear time-invariant system. For this system L[ . ] and shifting operators are reversible
as shown below.

𝑥(𝑛) → 𝐿[ . ] → 𝑦(𝑛) → 𝑆ℎ𝑖𝑓𝑡 𝑏𝑦̇ 𝑘 → 𝑦(𝑛 − 𝑘)

𝑥(𝑛) → 𝑆ℎ𝑖𝑓𝑡 𝑏𝑦̇ 𝑘 → 𝑥(𝑛 − 𝑘) → 𝐿[ . ] → 𝑦(𝑛 − 𝑘)


(5-4)
𝒚(𝒏) = 𝑳𝑻𝑰[𝒙(𝒏)] = ∑ 𝒙(𝒙)𝒉(𝒏 − 𝒌)
𝒌=−∝

Hence we can say that LTI system is completely characterized in the time domain by the
impulse response h(n) as shown below.

𝑥(𝑛) → ℎ(𝑛) → 𝑦(𝑛) = 𝑥(𝑛) ∗ ℎ(𝑛)

STABILITY
The primary reason for considering stability is to avoid building harmful systems or to avoid
burnout or saturation in the system operation. A system is said to be bounded-input bounded–
output (BIBO) stable if every bounded input produces a bounded output.

|x(n)| <∝⇒ |y(n)| <∝, ∀x, y


Note: An LTI system is BIBO stable if and only if its impulse response is absolutely summable.

37
Signals And Systems Lab Manual EL-315


(5-5)
𝑩𝑰𝑩𝑶𝑺𝒕𝒂𝒃𝒊𝒍𝒊𝒕𝒚 ⇔ ∑|𝒉(𝒏)| <∝
−∝

CAUSALITY
A system is said to be causal if the output at index “no” depends only on the input up to and
including the index “no” i.e. the output doesn’t depend on the future values of the input. An LTI
system is causal if and only if the impulse response

𝒉(𝒏) = 𝟎 , 𝒏 > 0 (5-6)

An LTI discrete system can also be described by a linear constant coefficient difference equation
of the form

𝑵 𝑴
(5-7)
∑ 𝒂𝒌 𝒚(𝒏 − 𝒌) = ∑ 𝒃𝒎 𝒙(𝒏 − 𝒎),
𝒌=𝟎 𝒎=𝟎

∀na𝑁 ≠ 0, then the difference equation is of order N.

This equation describes the recursive approach for computing the current output, given the
input values and previously computed output values. In practice this equation is computed
forward in time, from n = −∝ to n =∝ . Therefore another form of the equation is

𝑴 𝑵
(5-8)
𝒚(𝒏) = ∑ 𝒃𝒎 𝒙(𝒏 − 𝒎) − ∑ 𝒂𝒌 𝒚(𝒏 − 𝒌)
𝒎=𝟎 𝒌=𝟏

Solution to this problem can be obtained in the form


𝒚(𝒏) = 𝒚𝒉 (𝒏) + 𝒚𝒑 (𝒏) (5-9)

The homogeneous part of the solution,yh(n) , is given by

38
Signals And Systems Lab Manual EL-315

𝒚𝒉 (𝒏) = ∑ 𝒄𝒌 𝒛𝒌 𝒏 (5-10)
𝒌=𝟏

Where zk , k= 1,……. N, are N roots (also called natural frequencies) of the characteristic
equation.

∑ 𝒂 𝒌 𝒛𝒌 (5-11)
𝟎

This characteristic equation is important in determining the stability of systems. If roots


zk satisfies the condition.

|z𝑘 | < 1, 𝑘 = 1, … … . . , 𝑁

LAB TASK

Note: make m-file, show function’s plot, xlabel, ylabel,hold,stem and observe the output and
show to the instructor, see MATLAB help.

A routine called the FILTER is available to solve difference equations numerically , given the
input and the difference equation coefficients. This routine is invoked by

y = filter (b, a, x)

Where

B =[b0,b1,b2, ……bM]; a=[a0,a1,a2,…….aN];

X is input sequence array. Y output has the same length as input x. One must ensure that
coefficient a0 not to be zero.

1. y(n) − y(n − 1) + 0.9(n − 2) = x(n), ∀n


a. Calculate and plot the impulse response h(n) at n= -20, …., 100.
b. Calculate and plot the unit step response s(n) at n= -20, …., 100.

39
Signals And Systems Lab Manual EL-315

c. Is the system specified by h(n) stable?

TASK 1: MATLAB SCRIPT FOR IMPULSE RESPONSE

b=[1];
a=[1 -1 0.9];
x= impseq(0, -20, 120); n = [-120:120];
h=filter(b,a,x);
subplot(2,1,1); stem(n,h);title (‘impulse response’); xlabel(‘n’); ylabel(‘h(n)’)

Figure 5-1: Impulse Response


Note: see impseq function in previous lab manuals

TASK 2: MATLAB SCRIPT FOR STEP RESPONSE

x = stepseq(0 , -20, 120);


s=filter(b,a,x);
subplot(2,1,2); stem(n,s);
title (‘step response’); xlabel(‘n’); ylabel(‘s(n)’)

40
Signals And Systems Lab Manual EL-315

Figure 5-2: Step Response

Note: see stepseq function in previous lab manuals

To determine the stability of the system, we have to determine h(n)for all n. We can
use the plot of impulse response to observe that h(n) is practically zero for n > 120.
Hence the sum ∑|h(n)| can be determined from MATLAB using:

≫sum(abs(h))

≫ans =14.8785

Which implies that the system is stable. An alternate approach is to use the MATLAB
stability condition using MATLAB’s root function.

≫z = roots(a);
≫magz = abs(z)
Magz = 0.9487
0.9487

Since the magnitudes of both roots are less than one, the system is stable.

41
Signals And Systems Lab Manual EL-315

LAB ASSIGNMENT

P1. A particular linear and time-invariant system is described by the difference equations

y(n) − 0.5y(n − 1) + 0.25y(n − 2) = x(n) + 2x(n − 1) + x(n − 3)


Determine the stability of the system.
Determine and plot the impulse response of the system over 0 ≤ n ≤ 100.
Determine the stability from this impulse response.

42
Signals And Systems Lab Manual EL-315

Observations/Comments/Explanation of Results:

Score of Student in this Lab: _________________________________________

Instructor’s Signatures with Date: _____________________________________

43
Signals And Systems Lab Manual EL-315

Questions:

1. What is the difference between continuous and discrete time system?


2. What is linear system?
3. What is LTI system?
4. Explain Stability.
5. What is causality?
6. Explain ‘Filter’.
7. Explain ‘Stepseq’.
8. How will you determine stability of system in Matlab?
9. Explain ‘roots(a)’.
10. Explain subplot.

44
Signals And Systems Lab Manual EL-315

LAB-6: Simulation of Linear-Time-Invariant (LTI) system properties

Roll #:_____________________________

OBJECTIVES:

 To study and verify different properties of LTI system on MATLAB.

INTRODUCTION

We have defined the systems and their types in the previous lab session. In this lab we will
discuss the properties of LTI (Linear Time Invariant) systems. Linearity and time invariance play
a fundamental role in signal and system analysis. Many physical processes possess these
properties and thus can be modeled as linear time invariant (LTI) systems. One of the primary
reasons LTI systems are amenable to analysis is that these systems possess the superposition
property. As a consequence, if we can represent the input of an LTI system in terms of a linear
combination of a set of basic signals, we can then use superposition to compute the output of
the system in terms of its responses to these basic signals.

LINEAR TIME-INVARIANT (LTI) SYSTEM

A linear system in which an input-output pair, x(n) and y(n) , is invariant to a shift n in time is
called a linear time-invariant system. For this system L[ . ] and shifting operators are reversible
as shown below.

𝑥[𝑛] → 𝐿[ . ] → 𝑦[𝑛] → 𝑆ℎ𝑖𝑓𝑡 𝑏𝑦̇ 𝑘 → 𝑦[𝑛 − 𝑘]

𝑥[𝑛] → 𝑆ℎ𝑖𝑓𝑡 𝑏𝑦̇ 𝑘 → 𝑥[𝑛 − 𝑘] → 𝐿[ . ] → 𝑦[𝑛 − 𝑘]


(6-1)
𝒚[𝒏] = 𝑳𝑻𝑰[𝒙[𝒏]] = ∑ 𝒙[𝒌]𝒉[𝒏 − 𝒌]
𝒌=−∝

Hence we can say that LTI system is completely characterized in the time domain by the
impulse response h[n] as shown below.

𝑥[𝑛] → ℎ[𝑛] → 𝑦[𝑛] = 𝑥[𝑛] ∗ ℎ[𝑛]

45
Signals And Systems Lab Manual EL-315

If x1(t) and x2(t) are to signals and are input to LTI system then by law of superposition we get as
below

(6-2)
𝑳[𝒂𝟏 𝒙𝟏 (𝒕) + 𝒂𝟐 𝒙𝟐 (𝒕)] = 𝒂𝟏 𝑳[𝒙𝟏 (𝒕)] + 𝒂𝟐 𝑳[𝒙𝟐 (𝒕)], ∀𝒂𝟏 , 𝒂𝟐 𝒙𝟏 (𝒕), 𝒙𝟐 (𝒕)

(6-3)
𝑳[𝒂𝟏 𝒙𝟏 [𝒏] + 𝒂𝟐 𝒙𝟐 [𝒏]] = 𝒂𝟏 𝑳[𝒙𝟏 [𝒏]] + 𝒂𝟐 𝑳[𝒙𝟐 [𝒏]], ∀𝒂𝟏 , 𝒂𝟐 , 𝒙𝟏 [𝒏], 𝒙𝟐 [𝒏]

Eq.1 and 2 represents law of superposition on continuous and discrete linear time invariant
systems.

BASIC PROPERTIES OF LTI SYSTEMS

DISCRETE-TIME LTI SYSTEMS: THE CONVOLUTION SUM

The output of discrete-time LTI system is as follows where , h[n-k] denotes the response of
linear system to the shifted unit impulses 𝛿[𝑛 − 𝑘].
+∝
(6-4)
𝒚[𝒏] = ∑ 𝒙[𝒌]𝒉[𝒏 − 𝒌] = 𝒙[𝒏] ∗ 𝒉[𝒏]
−∝

CONTINUOUS-TIME LIT SYSTEMS: THE CONVOLUTION INTEGRAL


In case of continuous time it can be represented as

(6-5)
+∝
𝒚(𝒕) = ∫ 𝒙(𝒌)𝒉(𝒕 − 𝒌). 𝒅𝒌 = 𝒙(𝒕) ∗ 𝒉(𝒕)
−∝

46
Signals And Systems Lab Manual EL-315

THE COMMUTATIVE PROPERTY


A basic property of convolution in both continuous and discrete time is that it is a commutative
operation. That is, in discrete time
+∝
(6-6)
𝒙[𝒏] ∗ 𝒉[𝒏] = 𝒉[𝒏] ∗ 𝒙[𝒏] = ∑ 𝒙[𝒌]𝒉[𝒏 − 𝒌]
−∝

And in continuous time


+∝
(6-7)
𝒙(𝒕) ∗ 𝒉(𝒕) = 𝒉(𝒕) ∗ 𝒙(𝒕) = ∫ 𝒙(𝒌)𝒉(𝒕 − 𝒌). 𝒅𝒌 =
−∝

THE DISTRIBUTIVE PROPERTY

Convolution distributes over addition, so that in discrete time

(6-8)
𝒙[𝒏] ∗ (𝒉𝟏 [𝒏] + 𝒉𝟐 [𝒏]) = 𝒙[𝒏] ∗ 𝒉𝟏 [𝒏] + 𝒙[𝒏] ∗ 𝒉𝟐 [𝒏]

And in continuous time

(6-9)
𝒙(𝒕) ∗ (𝒉𝟏 (𝒕) + 𝒉𝟐 (𝒕)) = 𝒙(𝒕) ∗ 𝒉𝟏 (𝒕) + 𝒙(𝒕) ∗ 𝒉𝟐 (𝒕)

This property can be easily verified by the parallel interconnection of LTI systems.

THE ASSOCIATIVE PROPERTY

Another important and useful property of convolution is that it is associative. That is, in discrete
time

(6-10)
𝒙[𝒏] ∗ (𝒉𝟏 [𝒏] ∗ 𝒉𝟐 [𝒏]) = (𝒙[𝒏] ∗ 𝒉𝟏 [𝒏]) ∗ 𝒉𝟐 [𝒏]

47
Signals And Systems Lab Manual EL-315

Similarly in continuous time we get

(6-11)
𝒙(𝒕) ∗ (𝒉𝟏 (𝒕) ∗ 𝒉𝟐 (𝒕)) = (𝒙(𝒕) ∗ 𝒉𝟏 (𝒕)) ∗ 𝒉𝟐 (𝒕)

LIT SYSTEMS WITH AND WITHOUT MEMORY

A system is said to be memoryless if its output for each value of the independent variable at a
given time is dependent only on the input at the same time. For example, the system specified
by the relationship

𝑦[𝑛] = (2𝑥[𝑛] − 𝑥 2 [𝑛]2 )

Is memoryless, as value of y[n] depends only on the value of x[n] at that time.

An example of a discrete-time system with memory is an accumulator or summer and delay.

𝑦[𝑛] = ∑𝑛𝑘=−∞ 𝑥[𝑘] % summer/accumulator (6-12)

𝑦[𝑛] = 𝑥[𝑛 − 1] % delay

INVERTIBILITY OF LTI SYSTEMS


A system is said to be invertible if distinct inputs lead to distinct outputs. Furthermore if a
system is invertible, then an inverse system exists that , when cascaded with the original
system, yields an output equal to the input to first system.

𝑥[𝑛] → 𝑆𝑌𝑆𝑇𝐸𝑀 → 𝑦[𝑛] → 𝐼𝑁𝑉𝐸𝑅𝑆𝐸 𝑆𝑌𝑆𝑇𝐸𝑀 → 𝑥[𝑛]

CAUSALITY AND STABILITY OF LTI SYSTEMS

48
Signals And Systems Lab Manual EL-315

CAUSALITY
A system is said to be causal if the output at index “no” depends only on the input up to and
including the index “no” i.e. the output doesn’t depend on the future values of the input. An LTI
system is causal if and only if the impulse response

(6-13)
𝒉[𝒏] = 𝟎 , 𝒏 > 0

STABILITY

An LTI system is BIBO stable if and only if its impulse response is absolutely summable.

(6-14)

𝑩𝑰𝑩𝑶𝑺𝒕𝒂𝒃𝒊𝒍𝒊𝒕𝒚 ⇔ ∑|𝒉[𝒏]| <∝


−∝

TIME INVARIANCE OF LTI SYSTEM

A system is time invariant if the behavior and characteristics of the system are fixed over time.

(6-15)
𝑦(𝑡) = 𝑘. 𝑥(𝑡)
𝑦(𝑡 − 𝑡𝑜) = 𝑘. 𝑥(𝑡 − 𝑡𝑜)

LAB TASK

TASK 1:

If x1[n]=sin[n],and x2[n]=cos[n], consider a system y[n]= x[n].cos[0.2*pi*n]. Show if y[n] is linear or not.

Write the MATLAB code below.

49
Signals And Systems Lab Manual EL-315

TASK 2:

Considering y[n] defined above show, if this systemis time variant or invariant.

Write the MATLAB code below, and the result you get on the command window.

TASK 3:

Let x[n]=𝛿[𝑛] + 2𝛿[𝑛 − 1] − 𝛿[𝑛 − 3] %-10<=n<=+10


And h[n]= 2𝛿[𝑛 + 1] + 2𝛿[𝑛 − 1]

Compute and plot each of the following convolutions.

a. y1[n]=x[n]*h[n].
b. y2[n]=x[n]*h[n+2].

MATLAB CODE:

n=-10:10;
x=impseq(0,-10,10)+2.*impseq(1,-10,10)-impseq(3,-10,10);
h=2.*impseq(-1,-10,10)+2.*impseq(1,-10,10);

y1=conv(x,h);
y2=conv(x,sigshift(h,n,-2));

50
Signals And Systems Lab Manual EL-315

TASK 4:

If y[n]= x[n]*h[n] , where h[n]=n.(1/3)^n.u[n-1] , whereas


x1[n]=(0.5)^n.u[n] , x2[n]=u[n+3], x3[n]=δ[n]-δ[n-1].
Then find

a. y1[n]=x1[n]*x2[n]*x3[n] % convolve all


b. y2[n]= x1[n]*(x2[n]+x3[n]) % distributive property
Write the MATLAB CODE below.

TASK 5:

The following are the impulse responses of LTI-systems. Determine through MATLAB either
they are causal/stable. Taking -100<=n<=100

a. ℎ1[𝑛] = (5)𝑛 𝑢[3 − 𝑛]


1 𝑛
b. ℎ2[𝑛] = 𝑛 (3) 𝑢[𝑛 − 1]

Write the MATLAB Code below for h1 and h2.

sum(abs(h)) % this command will be used for stability.

51
Signals And Systems Lab Manual EL-315

LAB ASSIGNMENT

P1.

If there are three inputs


x1[n]=(0.5)^n.u[n] , x2[n]=u[n-3], x3[n]=δ[n]-δ[n-1]
y[n]= 2x[n]+10 then show that ,

a. y[n] is LTI-system.
b. Show x1,x2,x3 satisfy the commutative, distributive and associative law.

P2.

Which of the following impulse response corresponds to stable LTI systems?


1−2j
a. h1(t) = e− t u(t)

b. h2(t) = e−t cos(2t) u(t)

52
Signals And Systems Lab Manual EL-315

Observations/Comments/Explanation of Results:

Score of Student in this Lab: _________________________________________

Instructor’s Signatures with Date: _____________________________________

53
Signals And Systems Lab Manual EL-315

Questions:

1. What is linear system?


2. What is LTI system?
3. Explain different properties of LTI system.
4. Explain Stability.
5. What is causality?
6. Explain Invertibility.
7. What is convolution?
8. Explain “impseq”.
9. How will you find convolution in MATLAB?
10. Explain accumulator.

54
Signals And Systems Lab Manual EL-315

Lab-7: Continuous time convolution

Roll #:_____________________________

OBJECTIVES:

 Perform Continuous time convolution.


 Use of INT() command for performing integration.

INTRODUCTION

In this lab we will study continuous time convolution. The definition of convolution is a
mathematical operation on two functions to generate another function. In signals domain,
convolution is the operation on two signals to generate a new signal. Consider the following
system, now in continuous time:

x(t) h(t) y(t)

Fig.7-1

The output y(t) will be the convolution of input x(t) and impulse response of the system h(t).

CONTINUOUS TIME CONVOLUTION

In continuous time convolution we take input, impulse response and the output in continuous
time. The output then is represented by the convolution integral given by:

∞ ∞
y(t) = x(t) ∗ h(t) = ∫−∞ x(τ)h(t − τ)dτ =∫−∞ h(τ)x(t − τ)dτ (7-1)

55
Signals And Systems Lab Manual EL-315

The difference between continuous time convolution and discrete time convolution is that in
discrete time we take samples of our signal but in continuous time we take signal on the whole.
It is equivalent to saying that when we make infinite samples of our signal, then the samples
will be very close to each other and the summation becomes integration and discrete time
convolution becomes continuous time convolution. So in continuous time convolution we use
integration rather than summation as described in the equation above.

STEPS TO CARRY OUT CONTINUOUS TIME CONVOLUTION

Continuous time convolution is similar to discrete time convolution. Basic points to carry out
the convolution are bulleted below:

 Assume input x(t) and impulse response h(t) are available.


 Change the variable from t to τ of input and impulse response.
 Flip h(τ) to make it h(-τ). (We can reverse either x(τ) or h(τ) as per our choice).
 Shift h(-τ) to the left by t i.e. make it h(t -τ). Shift h(-τ) by such value that nothing is
common in h(t -τ) and x(τ)
 Slide h(t -τ) to the right over x(τ) region by region.
 Multiply the overlapping areas of regions and perform the integration.
 Carry on this process unless h(t -τ) slides past all of x(τ).
 The value of sum of all the integrated regions will be the convolution of x(t) and h(t).

EXAMPLE OF CONVOLUTION

Let us take on an example of convolution. Consider the input signal

x(t) = u(t-2) – u(t-4)

and the impulse response

h(t) = u(t-2) – u(t-4)

The input signal is:

56
Signals And Systems Lab Manual EL-315

Fig 7-2

The impulse response is given by:

Fig.7-3

And finally the output of the convolution of x(t) and h(t) is given by:

57
Signals And Systems Lab Manual EL-315

Fig.7-4

58
Signals And Systems Lab Manual EL-315

LAB TASK

By reading out the pre lab document most of us would have an idea about convolution. But that
was how we can perform convolution mathematically. In this lab handout we will explain how
convolution is done in MATLAB. By following the explained step by step procedure, we will
learn convolution using MATLAB.

TASK1: CONV FUNCTION

In the previous lab we performed convolution using ‘conv’ function. But problem with this built
in function is that is works only if the two signals are discrete time. This function is not defined
for continuous time signals. So, we cannot use ‘conv’ function in the case of continuous time
convolution.

ANY OTHER BUILT-IN FUNCTION?

There is no built in function for continuous time convolution in MATLAB. Then the obvious
question is how we can perform continuous convolution in MATLAB? Recall from your pre lab
handout that continuous time convolution is carried out by the expression:

∞ ∞
y(t) = x(t) ∗ h(t) = ∫−∞ x(τ)h(t − τ)dτ =∫−∞ h(τ)x(t − τ)dτ (7-2)

The integral used in the expression is the definite integral. MATLAB has a function called INT to
perform integration. To explore this function and its functionality type doc symbolic/int and
press enter.

59
Signals And Systems Lab Manual EL-315

LAB TASK

TASK 1:

>>doc symbolic/int

Write down what have you understood in “doc syms “ & “doc int “

TASK 2:

A window having detail of INT function will be opened.

Let us take an example regarding continuous time convolution:

Let us consider the convolution of 1/(1+t2) with itself. That is let us calculate
2𝜋
1 1
∫ ∗ 𝑑𝜏
1 + 𝜏 1 + (𝑡 − 𝜏)2
2
−2𝜋

To do this we have MATLAB commands

>>syms t tau

>> f=1/(1+t^2);

>> z=int(subs(f,tau)*subs(f,t-tau),tau,-2*pi,2*pi);

>> subplot(2,1,1);

>>ezplot(f);

>> xlabel(‘t’);

>>ylabel(‘f’);

>> grid on;

>> title(‘original signal ’);

>> subplot(2,1,2);

>> plot(z);

>> xlabel(‘t’);

60
Signals And Systems Lab Manual EL-315

>>ylabel(‘z’);

>> grid on;

>> title(‘continuous convolution ’);

The function should look like this:

Fig.7-5

and the convolution result is:

61
Signals And Systems Lab Manual EL-315

Fig.7-6

TASK 3:

Consider the input

x(t) = [1 - e-1.5t] 0≤t≤10

and the impulse response be

h(t) = [2te-t – e-3t] 0≤t≤10

and the output is defined as

y(t) = x(t) * h(t) % convolve x(t) with h(t)

You are required to:

Write the MATLAB code to find y(t).

Plot x(t), h(t) and y(t) in one window. (Hint: Use subplot).

Label x-axis of all three graphs as t.

Label y-axis of x(t), h(t) and y(t) as Input x(t), Impulse Response h(t) and Output y(t)
respectively.

62
Signals And Systems Lab Manual EL-315

Apply grid on all three graphs.

Give the title Convolution to all three graphs.

TASK 4:

Consider the input

x(t) = cos(t) 0≤t≤10

and the impulse response be

h(t) = sin(t) 0≤t≤8

and the output is defined as

y(t) = x(t) * h(t) % convolve x(t) with h(t)

You are required to:

 Write the MATLAB code to find y(t).


 Plot x(t), h(t) and y(t) in one window. (Hint: Use subplot).
 Label x-axis of all three graphs as t.
 Label y-axis of x(t), h(t) and y(t) as Input x(t), Impulse Response h(t) and Output y(t)
respectively.
 Apply grid on all three graphs.
 Give the title Convolution to all three graphs.

TASK 5:

Consider the input

x(t) = cos(t)+t 0≤t≤6

and the impulse response be

h(t) = sin(t)+e^2t 0≤t≤8

and the output is defined as

63
Signals And Systems Lab Manual EL-315

y(t) = x(t) * h(t) % convolve x(t) with h(t)

You are required to:

 Write the MATLAB code to find y(t).


 Plot x(t), h(t) and y(t) in one window. (Hint: Use subplot).
 Label x-axis of all three graphs as t.
 Label y-axis of x(t), h(t) and y(t) as Input x(t), Impulse Response h(t) and Output y(t)
respectively.
 Apply grid on all three graphs.
 Give the title Convolution to all three graphs.

64
Signals And Systems Lab Manual EL-315

LAB ASSIGNMENTS

Consider the input

x(t) = e-0.5t 0≤t≤10

and the impulse response be

h(t) = cos(t) 0≤t≤10

and the output is defined as

y(t) = x(t) * h(t) % convolve x(t) with h(t)

You are required to:

 Write the MATLAB code to find y(t).


 Plot x(t), h(t) and y(t) in one window. (Hint: Use subplot).
 Label x-axis of all three graphs as t.
 Label y-axis of x(t), h(t) and y(t) as Input x(t), Impulse Response h(t) and Output y(t)
respectively.
 Apply grid on all three graphs.
 Give the title Convolution to all three graphs.

62
Signals And Systems Lab Manual EL-315

Observations/Comments/Explanation of Results:

Score of Student in this Lab: ___________________________________________

Instructor’s Signatures with Date: ________________________________________

63
Signals And Systems Lab Manual EL-315

Questions:

1. What is convolution.
2. Explain types of convolution.
3. What are different steps to carry out convolution?
4. How will you find convolution in MATLAB?
5. What is the difference between plot and stem?
6. How will you apply grid on graphs?
7. How will you write x(t) in MATLAB?
x(t) = u(t-2) – u(t-4)
8. Explain ‘syms’.
9. Explain ‘int’.
10. Explain ‘ezplot’.

64
Signals And Systems Lab Manual EL-315

Lab-8: Discrete time convolution


Roll #:_____________________________

OBJECTIVES:

 Figure out deficiency of conv() command


 Make a function to perform proper convolution sum along with index calculation.

INTRODUCTION

Convolution is a mathematical operation on two functions to generate another function. In the


signals domain convolution is the operation on two signals to generate a new signal. Consider
the following system:

x[n] y[n]

h[n]

Fig.8-1

The output y[n] will be the convolution of input x[n] and impulse response of the system will be
h[n].

TYPES OF CONVOLUTION

1. CONTINUOUS TIME

In continuous time convolution we take input, impulse response and the output in continuous
time. The output then is represented by the convolution integral given by:

65
Signals And Systems Lab Manual EL-315

∞ ∞ (8-1)
y(t) = x(t) ∗ h(t) = ∫−∞ x(τ)h(t − τ)dτ=∫−∞ h(τ)x(t − τ)dτ

2. DISCRETE TIME

In discrete time convolution we take input, impulse response and the output in discrete time.
The output then is represented by the convolution sum given by:

𝑦[𝑛] = 𝑥[𝑛] ∗ ℎ[𝑛] = ∑∞ ∞


𝑘=−∞ 𝑥[𝑘]ℎ[𝑛 − 𝑘] = ∑𝑘=−∞ ℎ[𝑘]𝑥[𝑛 − 𝑘]
(8-2)

STEPS TO CARRY OUT CONVOLUTION

Convolution is a step-by-step procedure. Basic points to carry out the convolution are bulleted
below:

 Assume input x[n] and impulse response h[n] are available.


 Change the variable from n to k of impulse response i.e. h[n] h[k].
 Flip h[k] to make it h[-k]. (We can reverse either x[n] or h[n] on our choice).
 Shift h[k] to the left by n i.e. make it h[n-k].
 Slide h[n-k] to the right over x[n] index by index.
 Multiply the overlapping weights of indices and calculate the sum.
 Carry on this process unless h[n-k] slides past all of x[n].
 The value of sum will be the convolution sum of x[n] and h[n].

EXAMPLE OF CONVOLUTION

Let us take on an example of convolution. Consider the input signal

x[n] = u[n] – u[n-3]

and the impulse response

h[n] = u[n] – u[n-2]

The input signal is:

66
Signals And Systems Lab Manual EL-315

Fig.8-2

The impulse response is given by:

Fig.8-3

And finally the output of the convolution of x[n] and y[n] is given by:

67
Signals And Systems Lab Manual EL-315

Fig.8-4

68
Signals And Systems Lab Manual EL-315

LAB TASK

By reading out the pre lab document most of us would have an idea about convolution. But that
was how we can perform convolution mathematically. In this lab handout we will explain how
convolution is done in MATLAB. By following the explained step by step procedure, we will
learn convolution using MATLAB.

TASK1: CONV FUNCTION

MATLAB provides a built in function named conv(x,h) that computes the convolution of two
signals. Let us take on an example to explore this function.

EXAMPLE

>> x = [3,11,7,0,-1,4,2];

>> h = [2,3,0,-5,2,1];

>> y = conv(x,h)

y=

6 31 47 6 -51 -5 41 18 -22 -3 8 2

This convolution functions proves to be very useful but it misses one of the most important
things of convolution which is discussed below.

PROBLEM WITH BUILT-IN CONV FUNCTION

69
Signals And Systems Lab Manual EL-315

The conv function assumes that the two sequences begin at n = 0. Moreover, this function
neither provides nor accepts any timing information if the sequences have arbitrary starting
points. What is required is the beginning and end point of y[n]. Given finite duration x[n] and
h[n], it is easy to determine these points. Let

{x[n]; nxb ≤ n ≤ nxe}

And

{h[n]; nhb ≤ n ≤ nhe}

be the two finite duration sequences, then starting and end points of y[n] can be written as

nyb = nxb + nhb and nye = nxe+nhe

TASK2: MAKING OUR OWN CONVOLUTION FUNCTION (MYCONV)

Now we can define our own function in MATLAB that is slightly modified from the built in conv
function. Our modified function will use the conv function as underlying function but it will
perform convolution of arbitrary support sequences. How to define our own function?

First go to File and then click New and then M-File. Write the following code in the newly
opened editor file.

function [y,ny] = myconv(x,nx,h,nh)

%[y,ny] = convolution result

%[x,nx] = First signal

%[h,nh] = Second signal

nyb = nx(1) + nh(1);

nye = nx(length(x)) + nh(length(h));

ny = [nyb : nye];

y = conv(x,h);

70
Signals And Systems Lab Manual EL-315

end

This is our own defined function named myconv. Now we can use this function just as any other
function in MATLAB.

Now we will use this function for the convolution of signals having arbitrary starting and ending
points. Consider the signals in previous example

TASK3: MY CONV FUNCTION

>> x = [3,11,7,0,-1,4,2];

>>nx = [-3:3];

>> h = [2,3,0,-5,2,1];

>>nh = [-1:4];

>> [y,ny] = myconv(x,nx,h,nh)

y=

6 31 47 6 -51 -5 41 18 -22 -3 8 2

ny =

-4 -3 -2 -1 0 1 2 3 4 5 6 7

Now this function also shows the starting and ending points of y[n] and values are
corresponding indices. We can plot this y[n] by the commands:

>> stem(ny,y);

>> xlabel('n');

>>ylabel('y[n]');

>> title('Convolution');

71
Signals And Systems Lab Manual EL-315

The output should be like this:

Fig.8-5

TASK4:

Consider the input signal

x[n] = u[n+2] – u[n-2]

and impulse response of the system as

h[n] = u[n+2] – u[n-2]

Both input and impulse response is taken to be the same for the sake of simplicity. We define
output as the convolution of input and impulse response.

y[n] = x[n] * h[n].

You are required to:

 Write the MATLAB code to find y[n].


 Plot x[n], h[n] and y[n] in one window. (Hint: Use subplot).
 Label x-axis of all three graphs as n.
 Label y-axis of x[n], h[n] and y[n] as Input x[n], Impulse Response h[n] and Output y[n]
respectively.

72
Signals And Systems Lab Manual EL-315

 Apply grid on all three graphs.


 Give the title Convolution to all three graphs.

TASK5: CONV FUNCTION

Consider the input signal

x[n] = 1, 0 ≤ n ≤ 4

0, otherwise

and the impulse response of the system as

h[n] = 0.5n, 0 ≤ n ≤ 6

0, otherwise

then the output will be

y[n] = x[n] * h[n]

You are required to:

 Write the MATLAB code to find y[n].


 Plot x[n], h[n] and y[n] in one window. (Hint: Use subplot).
 Label x-axis of all three graphs as n.
 Label y-axis of x[n], h[n] and y[n] as Input x[n], Impulse Response h[n] and Output y[n]
respectively.
 Apply grid on all three graphs.
 Give the title Convolution to all three graphs.

73
Signals And Systems Lab Manual EL-315

LAB ASSIGNMENTS

P.1

When the convolution of a signal is performed with itself, it is called correlation which is a very
important concept in communications. This task is related to this concept. You have to convolve
the signal with itself. The signal is given by:

x[n] = 1, -2≤n≤0

-1, 0<n≤2

You are required to:

 Write the MATLAB code to find y[n].


 Plot x[n] and y[n] in one window. (Hint: Use subplot).
 Label x-axis of both graphs as n.
 Label y-axis of x[n] and y[n] as Input x[n] and Output y[n] respectively.
 Apply grid on all three graphs.
 Give the title Convolution to both the graphs.

73
Signals And Systems Lab Manual EL-315

Observations/Comments/Explanation of Results:

Score of Student in this Lab: ___________________________________________

Instructor’s Signatures with Date: _______________________________________

74
Signals And Systems Lab Manual EL-315

Questions:

1. What is convolution.
2. Explain types of convolution.
3. What are different steps to carry out convolution?
4. How will you find convolution in MATLAB?
5. What is the difference between plot and stem?
6. How will you apply grid on graphs?
7. How will you write x[n] in MATLAB?
x[n] = 1, 0 ≤ n ≤ 4
0, otherwise

75
Signals And Systems Lab Manual EL-315

Lab-9: Fourier series, magnitude and phase calculation on Matlab


Roll #:_____________________________

OBJECTIVES:

 To plot Saw-Tooth wave form.


 To find Fourier series magnitude and phase characteristics.
 Form a function to find Fourier series coefficients.

INTRODUCTION

Transforms are used extensively in engineering to change the frame of reference between the
time domain and the frequency domain. Many techniques exist for analyzing steady-state and
smoothly changing systems in the time domain, but complex systems often can be more easily
analyzed in other domains.
Fourier series and the Fourier transform play a vital role in many areas of engineering such as
communications and signal processing. These representations are among the most powerful
and most common methods of analyzing and understanding signals. A solid understanding of
Fourier series and the Fourier transform is critical to the design of filters and is beneficial in
developing the understanding of many natural phenomena.

FOURIER SERIES

Almost all periodic signals can be represented as an infinite sum of sine and cosines. This sum is
called a Fourier series representation and is defined for a periodic function x(t) of period T with
the following equation,


(9-1)
𝒂𝟎 𝟐𝝅𝒏𝒕 𝟐𝝅𝒏𝒕
𝒙(𝒕) = + ∑ (𝒂𝒏 𝐜𝐨𝐬 + 𝒃𝒏 𝐬𝐢𝐧 )
𝟐 𝑻 𝑻
𝒏=𝟏

Where a0, an and bn are the Fourier series coefficients. These coefficients can be calculated by
applying the following equations:

𝑻 𝑻 (9-2)
𝟐 𝟐𝝅𝒏𝒕 𝟐 𝟐𝝅𝒏𝒕
𝒂𝒏 = ∫ 𝒙(𝒕) 𝐜𝐨𝐬 𝐝𝐭 𝐚𝐧𝐝 𝒃𝒏 = ∫ 𝒙(𝒕) 𝐬𝐢𝐧 𝐝𝐭
𝑻 𝑻 𝑻 𝑻
𝟎 𝟎

76
Signals And Systems Lab Manual EL-315

If the Fourier coefficients are written as a single complex number cn with real part representing
the coefficients of the cosine series and imaginary parts representing coefficients of the sine
series, we can write the complex form of the Fourier series as

1 𝑇
x(t) = ∑+∞
−∞ cn𝑒 (𝑗2𝜋𝑛𝑡/𝑇) with cn = 𝑇 ∫0 𝑥(𝑡) 𝑒 (−𝑗2𝜋𝑛𝑡/𝑇) n = 0, 1, 2....

LAB TASK

TASK1:

Fourier series of Saw Tooth Wave

1. Plot of saw tooth wave

In this section we take an arbitrary saw tooth wave and plot it. Next we plot the magnitude and
phase of the Fourier co-efficient. Then reconstruct the saw tooth wave by combining various
harmonics.

>> x = [0.1 0.9 0.1]; % 1 period of x(t)


>> x = [x xx x]; % 4 periods of x(t)
>>tx = [ -2 -1 0 0 1 2 2 3 4 4 5 6 ]; % time points for x(t)
>>plot ( tx , x );
>>grid;
>>xlabel ( ‘ Time (sec) ‘ ) ;
>>ylabel ( ‘ Amplitude ‘ );
>>title ( ‘ Periodic Signal x(t) ‘ ) ;
>>axis ( [ -2 6 0 1 ] ) ;

77
Signals And Systems Lab Manual EL-315

Figure 9-1

TASK2: Magnitude and Phase

>> a0 = 0.5; % DC component of Fourier series


>> ph0 = 0;
>> n = [1 3 5 7 9]; % value of n to be evaluated
>>an = -pi./ ( pi * n ) .^2 ; % Fourier Series C officients
>>mag_an = abs (an);
>>phase_an = -180 * ones (1, length (n));
>> n = [0 n];
>>mag_an = [a0 mag_an]; % including a0 with a_n;
>>phase_an = [ph0 phase_an];
>> figure (2);
>>clf;
>>subplot (2, 1 , 1);
>> plot (n, mag_an, ‘o’);
>>grid;
>>xlabel( ‘ Harmonic Number’);
>>ylabel (‘Magnitude’);

78
Signals And Systems Lab Manual EL-315

>>title (‘ Fourier Series Magnitude ‘ );


>>axis ( [ 0 10 0 0.6 ] );
>>subplot ( 2 , 1, 2);
>> plot (n,phase_an, ‘o’);
>>grid;
>>xlabel( ‘ Harmonic Number’);
>>ylabel (‘Phase (radians)’);
>>title (‘ Fourier Series Phase ‘ );

Figure 9-2

79
Signals And Systems Lab Manual EL-315

TASK3:

function [Xk]=dfs(xn,N)
%computes discrete fourier series coefficients
n=[0:1:N-1];
k=[0:1:N-1];
WN=exp(-j*2*pi/N);
nk=n'*k;
WNnk=WN.^nk;
Xk=xn*WNnk;
end

Consider the signals given below

X1(n) = [2,0,2,0]; N=4;

and

x2(n) = [2,0,2,0]; N=4;

You are required to:

 Write the MATLAB code given above for DFS and calculate Xk;
 stem x1(n), x2(n) and Xk1(n) and Xk2(n)in one window. (Hint: Use subplot).
 Label x-axis of all three graphs as n
 Label y-axis of x1(n), x2(n) and Xk1(n) and Xk2(n) respectively.
 Apply grid on all three graphs.

Give a title to all four graphs

TASK4:

As by definition,

𝑎0 2𝜋𝑛𝑡 2𝜋𝑛𝑡
𝑥(𝑡) = + ∑ (𝑎𝑛 cos + 𝑏𝑛 sin )
2 𝑇 𝑇
𝑛=1
and

80
Signals And Systems Lab Manual EL-315

𝑇 𝑇
2 2𝜋𝑛𝑡 2 2𝜋𝑛𝑡
𝑎𝑛 = ∫ 𝑥(𝑡) cos dt and 𝑏𝑛 = ∫ 𝑥(𝑡) sin dt
𝑇 𝑇 𝑇 𝑇
0 0

If , our x(t)= sin(t) , with T=2∏, then find out the values of an, bn, and calculate x(t).

0 ≤t≤2∏ , write its MATLAB CODE BELOW.

81
Signals And Systems Lab Manual EL-315

LAB ASSIGNMENT

Consider the signals given below


−0.3𝑛
𝑥1(𝑛) = { 𝑛𝑒 , 0 ≤ 𝑛 ≤ 25 , 𝑁 = 50
0 26 ≤ 𝑛 ≤ 49

And
−0.3𝑛
𝑥2(𝑛) = { 𝑛𝑒 , 0 ≤ 𝑛 ≤ 25 , 𝑁 = 100
0 26 ≤ 𝑛 ≤ 99

You are required to:

 Call DFS function used in TASK3 and calculate Xk1,and Xk2;


 stem x1(n), x2(n) and Xk1(n) and Xk2(n)in one window. (Hint: Use subplot).
 Label x-axis of all three graphs as n
 Label y-axis of x1(n), x2(n) and Xk1(n) and Xk2(n) respectively.
 Apply grid on all three graphs.
Give a title to all four graphs

82
Signals And Systems Lab Manual EL-315

Observations/Comments/Explanation of Results:

Score of Student in this Lab: _________________________________________

Instructor’s Signatures with Date: _____________________________________

83
Signals And Systems Lab Manual EL-315

Questions:

1. Explain Fourier Series.


2. How will you plot Saw Tooth Waveform?
3. What is dicrete fourier series?
4. How will you write x(n) in MATLAB
−0.3𝑛
𝑥(𝑛) = { 𝑛𝑒 , 0 ≤ 𝑛 ≤ 25 , 𝑁 = 50
0 26 ≤ 𝑛 ≤ 49

5. Explain function DFS.


6. How will you find fourier series coefficients?

84
Signals And Systems Lab Manual EL-315

Lab-10: Fourier Transform


Roll #:_____________________________

OBJECTIVES:

 Be able to find Fourier Transform and Inverse Fourier Transform


 Be able to use fourier(), ifourier(), pretty(), heaviside(), dirac() functions.

FOURIER TRANSFORM

We can then extend the ideas of frequency decomposition to non-periodic signals via the
Fourier Transform. A Fourier transform can be used to analyze a circuit in the frequency domain
much like the Laplace transform can be used to analyze circuits in the s domain. The Fourier
transform is defined by

+∞ 𝟏 +∞ (10-1)
X(ω) = ∫−∞ 𝒙(𝒕)𝒆−𝒋𝝎𝒕 dt ; x(t) = ∫ 𝑿(𝝎) 𝒆𝒋𝝎𝒕 dω
𝟐𝝅 −∞

MATLAB used the fourier and ifourier functions to transform expressions between domains.

x(t) <——> X(w)

>>help fourier

>>help ifourier

85
Signals And Systems Lab Manual EL-315

LAB TASK

TASK1.

MATLAB uses a w to represent w in symbolic expressions.

>>doc fourier
Write about ‘fourier ’what you have understood.

>>syms t
>>x1 = t*exp(-t^2) % hit enter and write the output
x1=

>>f1 = fourier(x1) %hit enter and write the output


f1 =

>>if1=ifourier( f1 , ’t’ ) %hit enter and write the output


if1 =

>>ezplot(f1) %hit enter and show output

TASK2.

Often when using the Fourier transform to solve engineering problems, expressions can include
a step function u(t) and/or impulse function δ(t).

Consider the signal


X2 (t) = -e- t u(t) + 3 δ(t).

The Fourier transform can be found by:

>>x2=-exp(-t) * heaviside(t) + 3 * dirac(t) %hit enter and write output


>>x2 =

>>f2=fourier( -exp(-t) * heaviside(t) + 3 * dirac(t) ) %hit enter

86
Signals And Systems Lab Manual EL-315

f2 =

>>pretty (f2) %hit enter

Ans=

>>if2=ifourier(f2 , ’t’ ) %find the inverse Fourier transform, hit enter

if2 =

>> pretty(if2) %hit enter

>>ans=

>>ezplot(f2) %hit enter and show output

TASK 3.

Sgn (t) <——> 2/j *w

x3 = heaviside (t) - heaviside (- t); %hit enter

x3=

f3 = fourier (x3) %hit enter

f3 =

>>ezplot (abs(f3))

87
Signals And Systems Lab Manual EL-315

Figure 10-1
>>ezplot ( abs (f3) , [ -10 10] )

Figure 10-2

>>syms w
>>ezplot ( w , abs ( f3) , [ -5 5 -10 10 ] )

88
Signals And Systems Lab Manual EL-315

Figure 10-3
>> axis ( [ -5 5 -10 10 ] );

Figure 10-4
QUESTION: - What is the difference in the three plots???

__________________________________________________________________

__________________________________________________________________

__________________________________________________________________

89
Signals And Systems Lab Manual EL-315

LAB ASSIGNMENT

P1.

Plot the Fourier and its inverse transforms of: e– at u (t).

P2.

Plot the Fourier and its inverse transforms of: sine(t)*e– 10tu (t).

90
Signals And Systems Lab Manual EL-315

Observations/Comments/Explanation of Results:

Score of Student in this Lab: _________________________________________

Instructor’s Signatures with Date: _____________________________________

91
Signals And Systems Lab Manual EL-315

Questions:

1. Explain Fourier Transform.


2. Explain Inverse Fourier transform.
3. What Matlab command is used to compute fourier transform?
4. Explain ‘syms’.
5. How will you wite δ(t) in MATLAB?
6. How will you wite u(t) in MATLAB?
7. Explain Heaviside(t) function.
8. How will you write sgn(t) in matlab?
9. Explain ‘pretty’.
10. Explain ‘ezplot’.

92
Signals And Systems Lab Manual EL-315

Lab-11: Time and frequency characterization of signals and systems


Roll #:_____________________________

OBJECTIVES:

 Determine magnitude-phase representation of the fourier transform


 Determine magnitude-phase representation of the frequency response of LTI systems
 Differentiate between Linear and nonlinear phase
 Study Group delay, Log-magnitude and bode plots

INTRODUCTION

The frequency-domain characterization of an LTI-system in terms of its frequency response


represents an alternative to the time-domain characterization through convolution. In
analyzing LTI systems, it is often particularly convenient to utilize the frequency domain
because differential and difference equations and convolution operations in the time domain
become algebraic operations in the frequency domain. Hence in system design and analysis, it
is important to relate time-domain and frequency-domain characteristics and trade-offs. We
will discuss these characterizations in this lab session.

MAGNITUDE-PHASE REPRESENTATION OF THE FOURIER TRANSFORM

The Fourier transform is in general complex valued and can be represented in terms of its real
and imaginary components or in terms of magnitude and phase.

𝑋(𝑗𝜔) = |𝑋(𝑗𝜔)|𝑒 𝑗≮𝑋(𝑗𝜔) (11-1)

Eq.1 represents the magnitude-phase representation of the continuous-time Fourier transform


𝑋(𝑗𝜔)

Similarly in case of discrete-time signal eq.1 becomes


𝑗𝜔 ) (11-2)
𝑋(𝑒 𝑗𝜔 ) = |𝑋(𝑗𝜔)|𝑒 𝑗≮𝑋(𝑒

MAGNITUDE-PHASE REPRESENTATION OF THE FREQUENCY RESPONSE OF LTI SYSTEMS

93
Signals And Systems Lab Manual EL-315

From the convolution property for continuous-time Fourier transforms, transform 𝑌(𝑗𝜔) of the
output of an LTI system is related to the transform 𝑋(𝑗𝜔) of the input to the system by the
equation below.

𝑌(𝑗𝜔) = 𝑋(𝑗𝜔)𝐻(𝑗𝜔) (11-3)

Eq.1 represents the magnitude-phase representation of the continuous-time Fourier transform


(𝑗𝜔) :

Similarly in case of discrete-time signal eq.3 becomes

𝑌(𝑒 𝑗𝜔 ) = 𝑋(𝑒 𝑗𝜔 )𝐻(𝑒 𝑗𝜔 ) (11-4)

Thus the magnitude-phase notation of Eq.3 becomes

|𝑌(𝑗𝜔)|=|𝑋(𝑗𝜔)||𝐻(𝑗𝜔)|

≮ 𝑌(𝑗𝜔) =≮ 𝑋(𝑗𝜔)+≮ 𝐻(𝑗𝜔)


𝑚 𝑛 (11-5)
𝑌(𝑗𝜔)
𝐻(𝑗𝜔) = = ∑ 𝑏𝑘(𝑗𝜔)𝑘 / ∑ 𝑎𝑘(𝑗𝜔)𝑘
𝑋(𝑗𝜔)
𝑘=0 𝑘=0

LINEAR AND NONLINEAR PHASE

When the phase shift at the frequency ω is a linear function of ω , there is a particularly
straightforward interpretation of the effect in the time domain. Consider the continuous-time
LTI system with frequency response.

𝐻(𝑗𝜔) = 𝑒 −𝑗𝜔𝑡𝑜

So that the system has unit gain and linear phase. i.e

|𝐻(𝑗𝜔)| = 1 , ≮ 𝐻(𝑗𝜔) = −𝜔𝑡𝑜

The system with this frequency response characteristic produces an output that is simply a time
shift of the input.

𝑦(𝑡) = 𝑥(𝑡 − 𝑡𝑜)

94
Signals And Systems Lab Manual EL-315

GROUP DELAY

In continuous-time, if ≮ 𝐻(𝑗𝜔)= -ωto, then system imparts a time shift of –to, or equivalently,
a delay of to. The concept of delay can be very naturally and simply extended to include
nonlinear phase characteristics. Group delay at each frequency equals the negative of the
slope of the phase at that frequency. Group delay is defined as

𝑑
𝜏(𝜔) = − |≮ 𝐻(𝑗𝜔)|
𝑑𝜔

LOG-MAGNITUDE AND BODE PLOTS

The phase relationship is additive, while the magnitude relationship involves the product of
|𝐻(𝑗𝜔)| and |𝑋(𝑗𝜔)|. Thus, if the magnitudes of the Fourier transform are displayed on a
logarithmic amplitude scale then it takes the form of an additive relationship, namely

𝑙𝑜𝑔|𝑌(𝑗𝜔)| = 𝑙𝑜𝑔|𝐻(𝑗𝜔)| + 𝑙𝑜𝑔|𝑋(𝑗𝜔)|

Consequently, if we have a graph of the log magnitude and phase of the Fourier transform of
the input and the frequency response of LTI system, the Fourier transform of the output is
obtained by adding the log-magnitude plots and by adding the phase plots. In addition,
plotting the magnitude on logarithmic scale allows detail to be displayed over a wider
dynamic range.

NOTE:
Typically, the specific, logarithmic amplitude scale used is in units of 20log10, referred to as
decibels (db). 0db corresponds to a frequency with magnitude equal to 1, 20 db is equal to 10,
and -20 shows 0.1 attenuation and so on. 6db corresponds to a gain of 2.

95
Signals And Systems Lab Manual EL-315

LAB TASK
Note: show function’s plot,xlabel,ylabel,hold,ezplot and observe the output and show to the
instructor, see MATLAB help.

TASK 1:

syms x;
f = exp(-x^2)*heaviside(x) %Hit enter
fourier(f) %Hit enter

returns

ans = %write the answer below

TASK 2:

10
𝑖𝑓𝑥(𝑡) = 𝑒 −5𝑡 𝑢(𝑡), 0 ≤ 𝑡 ≤ 10 find 𝑥(𝑗𝜔) = ∫0 𝑒 −5𝑡 𝑒 −𝑗𝜔𝑡 𝑑𝑡

Solution:

syms t w

y=exp(-5*t)*heaviside(t); %Hit enter


fr=fourier(y)

fr= %write your answer

Now plotting magnitude and phase response (frequency responce)

ezplot(real(fr)) %Hit enter shows magnitude plot


ezplot(imag(fr)) %Hit enter shows phase response

96
Signals And Systems Lab Manual EL-315

Fig 11-1. Shows the magnitude plot of the function.

Fig 11-2. Shows the phase response of the above given function.

97
Signals And Systems Lab Manual EL-315

TASK 3:

𝑖𝑓𝑥(𝑡) = 𝛿(𝑡), 𝑡ℎ𝑒𝑛𝑓𝑖𝑛𝑑𝑖𝑡𝑠𝑓𝑟𝑒𝑞𝑢𝑒𝑛𝑐𝑦𝑟𝑒𝑠𝑝𝑜𝑛𝑐𝑒 , 𝑓𝑖𝑛𝑑𝑖𝑡𝑠𝑔𝑟𝑜𝑢𝑝


− 𝑑𝑒𝑙𝑎𝑦𝑎𝑛𝑑𝑙𝑜𝑔𝑚𝑎𝑔𝑛𝑖𝑡𝑢𝑑𝑒𝑣𝑎𝑙𝑢𝑒𝑖𝑛𝑑𝑒𝑐𝑖𝑏𝑙𝑒𝑠

syms t

y=dirac(t); %Hit enter

fr=fourier(y) %Hit enter

ezplot(real(fr))

gd=-diff(abs(real(fr))) %%Hit enter, shows group delay

logmag=20*log(fr) %Hit enter

98
Signals And Systems Lab Manual EL-315

Fig 11-3. Shows that impulse has Fourier transform consisting of equal contributions at all
frequencies.

TASK 4:

𝒅𝒚(𝒕)
+ 𝟏𝟎𝒚(𝒕) = 𝒙(𝒕)
𝒅𝒙
Consider an LTI system represented by differential equation, find its frequency response.

Solution:

From eq. 5 as it represents the frequency response of LTI system, so we can represent the
above differential equation as :

syms t w

fr=1/j*w+10

>> subplot(2,1,1)

>>ezplot(real(fr))

99
Signals And Systems Lab Manual EL-315

>> xlabel('frequency w')

>>ylabel('|fr|')

>> title('magnitude plot of fr')

>> grid on

>> subplot(2,1,2)

>>ezplot(imag(fr))

>> xlabel('frequency w')

>>ylabel('angle of fr')

>> title('phase plot of fr')

>> grid on

>>gd=-diff(abs(real(fr))) %%Hit enter, shows group delay

>>gd =

Fig 11-4. Shows the magnitude and phase of fr

100
Signals And Systems Lab Manual EL-315

LAB ASSIGNMENT

P.1

Determine the frequency response of the following functions.


𝜋
c. sin( 4 + 2𝜋𝑡)

d. cos(𝜋62𝑡/10)

101
Signals And Systems Lab Manual EL-315

Observations/Comments/Explanation of Results:

Score of Student in this Lab: _________________________________________

Instructor’s Signatures with Date: _____________________________________

102
Signals And Systems Lab Manual EL-315

Questions:

1. Explain MAGNITUDE-PHASE representation of FOURIER TRANSFORM.


2. Explain LTI system.
3. Explain linear and non linear phase.
4. What is group delay?
5. Explain Bode plots.
6. Explain ‘syms’.
𝜋
7. Determine the frequency response of sin ( 4 + 2𝜋𝑡)

8. How will you wite cos(𝜋62𝑡/10) in MATLAB?

9. Explain ‘ezplot’.

103
Signals And Systems Lab Manual EL-315

Lab-12: Comparison of continuous-time & discrete-time Signals and


Sampling and Signal Reconstruction

Roll #:_____________________________

OBJECTIVES:
 Be able to explain CONTINUOUS-VALUED versus DISCRETE-VALUED SIGNALS.
 Be able to find Periods of Continuous and Discrete signals.
 Be able to explain Signal Sampling Theorem and Nyquist Rate.
 Be able to reconstruct the signal.

INTRODUCTION

CONTINUOUS-TIME SIGNALS

Continuous-time signals or analog signals are defined for every value of time and they take on
values in the continuous interval (a, b) , where ‘a’ can be -∞ or +∞. Mathematically these
functions are described by functions of a continuous-time variable.

DISCRETE-TIME SIGNALS

Discrete-time signals are defined only at certain specific values of time. These time instants
need not to be equidistant, but in practice they are usually taken as equally spaced intervals for
computational convenience and mathematical tractability. They may take real or complex
values.

CONTINUOUS-VALUED versus DISCRETE-VALUED SIGNALS

CONTINUOUS-VALUED SIGNALS

The values of a continuous-time or discrete-time signal can be continuous or discrete. If a signal


takes on all possible values on a finite or an infinite range, it is said to be continuous –valued
signal.

104
Signals And Systems Lab Manual EL-315

DISCRETE-VALUED SIGNALS

If the signal takes on values from a finite set of possible values, it is said to be a discrete-valued
signal.

NOTE: A discrete-time signal having a set of discrete values is called a digital signal.

THE CONCEPT OF FREQUENCY IN CONTINUOUS-TIME AND DISCRETE-TIME SIGNALS

The concept of frequency is directly related to the concept of time. Actually frequency has the
dimension of inverse time. Thus nature of time will affect the nature of the frequency
accordingly.

CONTINUOUS-TIME SINUSOIDAL SIGNALS

Consider the signal

xa(t) = Acos(Ωt+𝜃), −∞ < 𝑡 < +∞ (12-1)

𝑥𝑎(𝑡) denotes an analog signal. This signal is has amplitude A, frequency Ω, and phase θ.
Instead of Ω, we often use the frequency F in cycles per second or hertz (Hz) , where

𝛺 = 2𝜋𝐹

Hence we can rewrite as

xa(t) = Acos(2𝜋Ft+𝜃), −∞ < 𝑡 < +∞ (12-2)

The analog sinusoidal signal is characterized by the following properties.

 For fixed value of the frequency , F , 𝑥𝑎(𝑡) is periodic if Tp is fundamental time period
xa(t+ Tp) = xa(t)

Where Tp= 1/F .

105
Signals And Systems Lab Manual EL-315

 Continuous-time sinusoidal signals with distinct (different) frequencies are themselves


distinct.

 Increasing the frequency F results in an increase in the rate of oscillation of the signal, in
the sense that more periods are included in a given time interval.

DISCRETE-TIME SINUSOIDAL SIGNALS

Consider the signal

(12-3)
𝑥(𝑛) = 𝐴𝑐𝑜𝑠(𝜔𝑛 + 𝜃), −∞ < 𝑛 < +∞

𝑥(𝑛) denotes an discrete signal. This signal is has amplitude A, frequency ω , and phase θ.
Instead of 𝜔, we often use the frequency 𝑓 in cycles per second or hertz (Hz) , where

𝜔 = 2𝜋𝑓

Hence we can rewrite as

(12-4)
𝑥(𝑛) = 𝐴𝑐𝑜𝑠(2𝜋𝑓𝑛 + 𝜃), −∞ < 𝑛 < +∞

The discrete sinusoidal signal is characterized by the following properties.

 A discrete-time sinusoidal is periodic only if its frequency 𝑓 is a rational number.


𝑥(𝑛 + 𝑁) = 𝑥(𝑛)𝑓𝑜𝑟𝑎𝑙𝑙𝑛

Where N is called the fundamental period.

 The relationship is true for discrete-time signal periodicity if there exits an integer k such
that
2𝜋𝑓0 𝑁 = 2𝑘𝜋
𝑓0 = 𝑘/𝑁

Where k, and N are relative prime numbers after canceling common factor.

 Discrete-time sinusoidal whose frequencies are separated by an integer multiple of 2𝜋


are identical.

106
Signals And Systems Lab Manual EL-315

 High rate of oscillation is attained when 𝜔 = 𝜋𝑜𝑟𝜔 = −𝜋

 Increasing the frequency F results in an increase in the rate of oscillation of the signal, in
the sense that more periods are included in a given time interval.

Sampling and Signal Reconstruction

Signals such as speech, radar and sonar signals in practical use are all analog signals. In order to
apply digital processing methods to these signals, we have to convert them into the form
required i.e. the digital form. This procedure is termed Analog-to-Digital conversion is carried
out by ADC’s (Analog-to-Digital converters).

A/D conversion can be divided into three steps:

1. Sampling

This step involves converting continuous time signal to discrete time signals. This is done by
taking samples i.e. a continuous time signal input xa(t) will give an output in the discrete form
xa(nT) ≡ x(n) where T is the sampling interval.

2. Quantization

In this step, the discrete time continuous –valued signal is converted into a discrete-time,
discrete-valued (digital) system. The signal sample value is selected from a set of finite possible
values. The difference between unquantized sample (x(n)) and the quantized output (xq(n) ) is
the quantization error.

3. Coding

Each discrete value xq(n) is represented by a b-bit binary sequence.

SAMPLING OF ANALOG SIGNALS

Although many types of analog sampling techniques are available, periodic or uniform will be
discussed in this practical.

The relationship below describes the process.

107
Signals And Systems Lab Manual EL-315

(12-5)
𝑥(𝑛) = 𝑥𝑎 (𝑛𝑇), − ∞ < 𝑛 <∞

Where :

x(n) Discrete time signal obtained by taking samples of the analog signal every T seconds

Sampling period/sample interval –the time interval T between successive samples

Sampling rate (samples per second)/sampling frequency- this is the reciprocal of T which is
equal to 1/Fs

Periodic sampling establishes the relationship between time variable t in continuous-time


signals and time variable n in discrete time signals.

These two variables are linearly related through the sampling period T or through the sampling
rate Fs=1/T as

𝑛 (12-6)
𝑡 = 𝑛𝑇 =
𝐹𝑠

Due to the relationship stated above there exists another resultant relationship between the
frequency variable F (or Ω) for analog signals and the frequency variable f (or ω) for discrete
time signals.

(12-7)
𝑥𝑎 (𝑡) = 𝐴cos(2πFt+θ)

108
Signals And Systems Lab Manual EL-315

when sampled periodically at a rate Fs =1/T samples per second yields

(12-8)
𝑥𝑎 (𝑛𝑇) ≡ 𝑥(𝑛) = 𝐴cos(2πFt+θ)
2𝜋𝑛𝐹
= 𝐴 cos ( + 𝜃)
𝐹𝑠

(12-9)
𝑥(𝑛) = 𝐴cos(ωn+θ)

We can then deduce from Equation (12-8) and (12-9) that

𝐹 (12-10)
𝑓=
𝐹𝑠
And,

(12-11)
𝜔 = Ω𝑇

SAMPLING THEOREM

If the highest frequency obtained in an analog signal xa(t) is Fmax =B (where B=bandwidth ) and
the signal is sampled at a rate Fs>2Fmax then xa(t) can be exactly recovered from its sample
values using the interpolation function below:

109
Signals And Systems Lab Manual EL-315

(12-12)
𝑠𝑖𝑛2𝜋𝐵𝑡
𝑔(𝑡) =
2𝜋𝐵𝑡

Thus xa(t) may be expressed as

(12-13)
𝑛 𝑛
𝑥𝑎 (𝑡) = ∑ 𝑥𝑎 ( )𝑔(𝑡 − )
𝐹𝑠 𝐹𝑠

Where :

xa(n/Fs)= xa(nT) ≡ x(n) are the samples xa(t).

When the sampling of xa(t) is performed at the minimum sampling rate Fs=2B, the
reconstruction formula (8) becomes :

(12-14)
𝑛 sin 2𝜋𝐵(𝑡 − 𝑛/2𝐵)
𝑥𝑎 (𝑡) = ∑ 𝑥𝑎 ( ) )
2𝐵 2𝜋𝐵(𝑡 − 𝑛/2𝐵)

The sampling rate FN=2B=2Fmax is called the Nyquist rate.

LAB TASK

TASK 1:

𝑥1(𝑡) = cos 2𝜋(10)𝑡


𝑥2(𝑡) = cos 2𝜋(50)𝑡 if 𝐹𝑠 = 40𝐻𝑧
𝑓𝑖𝑛𝑑𝑖𝑛𝑔
a. 𝑥1(𝑛)
b. 𝑥2(𝑛)

Solution.:

110
Signals And Systems Lab Manual EL-315

X1=cos(2*pi*(10/40)*n)

X2=cos(2*pi*(50/40)*n)

As cos((5*pi*n)/2)=cos(2*pi*n+pi*n/2)=cos(pi*n/2) hence both x1, and x2 above signals are identical.

TASK 2:

if 𝑥𝑎(𝑡) = 3cos(300𝜋𝑡) and Fs =700 , then find ω and 𝑓 write MATLAB Command.

Solution:

F=300*pi/2*pi;

f=F/Fs;

w=2*pi*f; % write down values of f, and w.

TASK 3:

Let us now concentrate on the cosine signal of the form x[n] = Acos(w n +φ ) , where we have
renamed the amplitude as A. We willchange the parameter w0 to see its effect on periodicity.
We will take A as 1, φ as as0 and w0 as 1, π /4 and 3π /4 and generate and plot the
corresponding signals. For the first one, i.e. the cosine with w0 = 1, we will also plot an
envelope to better see that the signal is not periodic.

n=-10:0.1:10;
» w0=1;xn1=cos(w0*n);

111
Signals And Systems Lab Manual EL-315

» stem(n,xn1);hold on
» t=-10:0.1:10;
» xt=cos(t);
» plot(t,xt,'r');hold off
» axis([-10.5 10.5 -1 1]);xlabel('n');ylabel('x[n]')
» title('A Nonperiodic Discrete Time Cosine Signal')

» w0=pi/4;xn2=cos(w0*n);

» subplot(2,1,1);stem(n,xn2)

» title('Discrete Time Cosine Signals')

» w0=3*pi/4;xn3=cos(w0*n);
» subplot(2,1,2);stem(n,xn3);xlabel('n')

Note: Both signals have a period of 8.

TASK 4:

close all;

clear all;

t=-10:0.01:10;

T=8;

fm=1/T;

x=cos(2*pi*fm*t);

fs1=1.2*fm;

fs2=2*fm;

fs3=8*fm;

n1=-4:1:4;

xn1=cos(2*pi*n1*fm/fs1);

subplot(221)

plot(t,x);

112
Signals And Systems Lab Manual EL-315

xlabel('time in seconds');

ylabel('x(t)');

title('continous time signal');

subplot(222)

stem(n1,xn1);

hold on;

plot(n1,xn1);

xlabel('n');

ylabel('x(n)');

title('discrete time signal with fs<2fm');

n2=-5:1:5;

xn2=cos(2*pi*n2*fm/fs2);

subplot(223)

stem(n2,xn2);

hold on;

plot(n2,xn2);

xlabel('n');

ylabel('x(n)');

title('discrete time signal with fs=2fm');

n3=-20:1:20;

xn3=cos(2*pi*n3*fm/fs3);

subplot(224)

stem(n3,xn3);

hold on;

113
Signals And Systems Lab Manual EL-315

plot(n3,xn3);

xlabel('n');

ylabel('x(n)');

title('discrete time signal with fs>2fm');

TASK 5:

t=0:.1:20;

F1=.1;

F2=.2;

x=sin(2*pi*F1*t)+sin(2*pi*F2*t);

%plotting

figure(1);

subplot(2,1,1);

plot(t,x);

title('Original signal')

xlabel('t');

ylabel('x(t)');

subplot(2,1,2);

x_samples=x(1:10:201); %gets 21 samples of x.

stem(x_samples,'filled');

title('Sampled signal')

xlabel('n');

ylabel('x_s(n)');

axis([0 20 -2 2]);

114
Signals And Systems Lab Manual EL-315

TASK 6:

%starting reconstruction process

figure(2);

messagebox=msgbox(information,'Information','help');

subplot(2,1,2);

plot(t,x,'black');

hold on;

plot([0 20],[0 0],'black');

hold off;

xlabel('t');

ylabel('x(t)');

title('Original signal');

grid;

x_recon=0;

subplot(2,1,1);

for k=0:length(x_samples)-1

stem(0:length(x_samples)-1,x_samples,'filled');

if k==length(x_samples)-1

title('Reconstruction finished');

else

title('Sample by sample reconstruction');

end

grid on;

115
Signals And Systems Lab Manual EL-315

l=k:-.1:-20+k;

x_recon=x_recon+x_samples(k+1)*sinc(l);

axis([0 20 -2 2]);

hold;

plot(t,x_samples(k+1)*sinc(l),'r')

plot(t,x_recon);

hold off;

waitforbuttonpress;

end

116
Signals And Systems Lab Manual EL-315

LAB ASSIGNMENT

P.1

Determine which of the following sinusoidals are periodic and compute their fundamental
period.

e. cos(𝜋30𝑛/105)

f. sin(𝜋62𝑛/10)

P.2

Determine whether or not each of the following signals is periodic. In case a signal is periodic
, specify its fundamental period.

a. 𝑥(𝑛) = 3𝑐𝑜𝑠(5𝑡 + 𝜋/6)


b. 𝑥(𝑛) = cos(𝑛/8)cos(𝜋𝑛/8)

P.3

Consider an analog signal given below

𝑥𝑎(𝑡) = 3 cos(2000𝜋𝑡) + 5 cos(6000𝜋𝑡) + 10cos(12000𝜋𝑡)

a. What is the Nyquist rate for this signal?

b. If we sample it with Fs=5000 Hz, what signal we get after sampling.

117
Signals And Systems Lab Manual EL-315

Observations/Comments/Explanation of Results:

Score of Student in this Lab: ___________________________________________

Instructor’s Signatures with Date: _______________________________________

118
Signals And Systems Lab Manual EL-315

Questions:

1. Explain the difference between continuous time signals and discrete time signals.
2. Explain the difference between continuous valued signals and discrete valued signals.
3. Explain Sampling.
4. Explain Quantization.
5. Explain Signal Reconstruction.
6. Explain properties of analogue signals.
7. Explain properties of discrete sinusoidal signals.
8. What is sampling frequency?
9. What is nyquist rate?
10. What is the period of 𝑥(𝑛) = 3𝑐𝑜𝑠(5𝑡 + 𝜋/6)

119
Signals And Systems Lab Manual EL-315

Lab-13: Z-transform using ‘residuez’ method and pole-zero plots


Roll #:_____________________________

OBJECTIVES:
 Be able to explain Z- Transform: Uni-lateral and Bi-lateral
 Be able to observe properties of Z-transform: Linearity, Sample Shifting, Frequency
Shifting, Folding, Complex Conjugation, Differentiation, Multiplication, and Convolution.

THE Z-TRANSFORM

Discrete-Fourier transform represents discrete signals using complex exponential sequences. It


has advantages for LTI systems because it describes systems in the frequency domain using
frequency response function H(ejw ). However, there are two shortcomings to the Fourier
transform approach. Firstly, there are many useful signals in practice such as u(n) and nu(n)
for which the discrete-time Fourier transform does not exist. Secondly, the transient response
of a system due to initial conditions or due to changing inputs cannot be computed using the
discrete-time Fourier transform approach.

THE BILATERAL Z-TRANSFORM

The z-transform of a sequence x(n) is given by


(13-1)
𝐗(𝐳) = 𝐙[𝐱(𝐧)] = ∑ 𝐱(𝐧) 𝐳 −𝐧
𝐧=−∝

Where “z” is a complex variable. The set of z values for which X(z) exists is called the region of
convergence (ROC) is given by

Rx−< |z| < 𝑅𝑥 +

PROPERTIES OF THE Z-TRANSFORM

120
Signals And Systems Lab Manual EL-315

1. LINEARITY

𝒁[𝒂𝟏𝒙𝟏(𝒏) + 𝒂𝟐𝒙𝟐(𝒏)] = 𝒂𝟏𝑿𝟏(𝒛) + 𝒂𝟐𝑿𝟐(𝒛)]; 𝑹𝑶𝑪: 𝑹𝑶𝑪𝒙𝟏 ∩ 𝑹𝑶𝑪𝒙𝟐 (13-2)

2. SAMPLE SHIFTING

𝒁[𝒙(𝒏 − 𝒏𝒐)] = 𝒛−𝒏𝒐 𝑿(𝒁), 𝑹𝑶𝑪 ∶ 𝑹𝑶𝑪𝒙 (13-3)

3. FREQUENCY SHIFTING

𝒛 (13-4)
𝒁[𝒂𝒏 𝒙(𝒏)] = 𝑿 ( ) =; 𝑹𝑶𝑪 ∶ 𝑹𝑶𝑪𝒙𝒔𝒄𝒂𝒍𝒆𝒅𝒃𝒚|𝒂|
𝒂

4. FOLDING

𝟏 (13-5)
𝒁[𝒙(−𝒏)] = 𝑿 ( ) =; 𝑹𝑶𝑪 ∶ 𝒊𝒏𝒗𝒆𝒓𝒕𝒆𝒅𝑹𝑶𝑪𝒙
𝒛

5. COMPLEX CONJUGATION

𝒁[𝒙∗ (𝒏)] = 𝑿∗ (𝒛∗ ); 𝑹𝑶𝑪 ∶ 𝑹𝑶𝑪𝒙 (13-6)

6. DIFFERENTIATION IN THE Z- DOMAIN

𝐝𝐗(𝐳) (13-7)
𝐙[𝐧𝐱(𝐧)] = −𝐳
𝐝𝐳

7. MULTIPLICATION

121
Signals And Systems Lab Manual EL-315

𝒁[𝒙𝟏(𝒏)𝒙𝟐(𝒏)] (13-8)
𝟏
= ∮ 𝑿𝟏(𝒗)𝑿𝟐(𝒛⁄𝒗)𝒗−𝟏 𝒅𝒗; 𝑹𝑶𝑪 ∶ 𝑹𝑶𝑪𝒙𝟏 ∩ 𝒊𝒏𝒕𝒆𝒓𝒕𝒆𝒅𝑹𝑶𝑪𝒙𝟐
𝟐𝝅𝒋
𝒄

8. CONVOLUTION

𝒁[𝒙𝟏(𝒏) ∗ 𝒙𝟐(𝒏)] = 𝑿𝟏(𝒛)𝑿𝟐(𝒛); 𝑹𝑶𝑪 ∶ 𝑹𝑶𝑪𝒙𝟏 ∩ 𝑹𝑶𝑪𝒙𝟐 (13-9)

LAB TASK

TASK 1:

syms n;
f = n^4;
T1=ztrans(f)
T1 =

ezplot(T1)

TASK 2:

syms a z;
g = a^z;
T2=ztrans(f)
T2 =

ezplot(T2)

TASK 3:

syms a n w;
f = sin(a*n);
T3=ztrans(f , w)
T3 =

ezplot(T3)

122
Signals And Systems Lab Manual EL-315

TASK 4:

Similarly in MATLAB [p,r]=deconv(b,a) computes the result of dividing b by a in a polynomial


part P , and a remainder r. i.e

≫ x3 =[6,17,34,43,38,24];
≫ x1=[2,3,4];
≫ [x2,r] =deconv(x3,x1);

x2 =

r=

TASK 5:

In MATLAB the function ‘residuez’ is available to compute the residue part and direct (or
polynomial) terms of a rational function in 𝐳−𝐳 .

z
X(Z) =
3z2 − 4z + 1
Solution.
First rearrange X(Z) so that it is a function in ascending powers of z−1 .
z−1
X(Z) =
3 − 4z−1 + z−2

≫ b=[0,1];
≫ a=[3,-4,1];
≫ [R,p,C]=residuez[b,a];

R =

P =

C =

So,
0.5 0.5
X(Z) = −1

1−z 1 − 0.333z−1

123
Signals And Systems Lab Manual EL-315

TASK 5:

Similarly to convert back to the rational function form

≫ [b,a]=residuez[R,p,C]

b =

a =

So that
1
0 + z −1 z −1 z
x(z) = 3 = = 2
4 −1 1 −2 −1
3 − 4z + 1z −2 3z − 4z + 1
1− z + z
3 3

Now applying the same procedure determine inverse z-transform of


1
x(z) =
(1 − 0.9z −1 )2 (1 + 0.9z −1 )

Hint: use a=poly(0.9,0.9,-0.9) to determine polynomials of a. then apply ‘residuez’ method.

TASK 6:

Pole-zero plots
z
X(Z) =
3z 2 − 4z + 1

We can find the roots of the denominator polynomial in the following two ways.

(a)We can plot the zeros and poles either with zeros and poles in column vectors

>> den = [3 -4 1];

>> roots(den);

>>p=ans;

124
Signals And Systems Lab Manual EL-315

>>z=[0];

>>zplane(z,p)

Plot the output:

(b) We can plot numerator and denominator coefficients in row vectors


≫num=[0 1 0];

≫den=[3 -4 1];

≫zplane(num,den)

Plot the output:

125
Signals And Systems Lab Manual EL-315

LAB ASSIGNMENT

P1. For the given signal plot the pole-zero plot given below and write its code.
1
x(z) =
(1 − 0.9z −1 )2 (1 + 0.9z −1 )

126
Signals And Systems Lab Manual EL-315

Observations/Comments/Explanation of Results:

Score of Student in this Lab: _________________________________________

Instructor’s Signatures with Date: _____________________________________

127
Signals And Systems Lab Manual EL-315

Questions:

1. Explain Z-Transform.
2. Explain Bilateral Z-Transform.
3. What is region of convergence?
4. Explain properties of Z-Transform.
5. What is complex conjugation?
6. What Matlab command is used to compute Z-Transform?
7. Explain ‘residuez’.
8. Explain ‘deconv’.
9. Explain ‘zplane’.
10. Expalin’roots’.

128
Signals And Systems Lab Manual EL-315

LAB-14: Inverse z-transform on Matlab

Roll #:_____________________________

OBJECTIVE:

 To explain different properties of z-transform and calculate inverse z-transform on


MATLAB.

INVERSE Z-TRANSFORM

SYNTAX

f = iztrans(F)
f = iztrans(F,k)

DESCRIPTION

f = iztrans(F) computes the inverse z-transform of the symbolic expression F. This syntax
assumes that F is a function of the variable z, and the returned value f is a function of n.

where R is a positive number, such that the function F(z) is analytic on and outside the circle
|z| = R.

If F = F(n), iztrans computes the inverse z-transform f as a function of the variable k.

f = f(k)

f = iztrans(F,k) computes the inverse z-transform f as a function of the variable k instead of the
default variable n.

f = iztrans(F,w,k) computes the inverse z-transform and lets you specify that F is a function of w
and f is a function of k.

129
Signals And Systems Lab Manual EL-315

PROPERTIES OF THE Z-TRANSFORM

9. LINEARITY

𝒁[𝒂𝟏𝒙𝟏(𝒏) + 𝒂𝟐𝒙𝟐(𝒏)] = 𝒂𝟏𝑿𝟏(𝒛) + 𝒂𝟐𝑿𝟐(𝒛)]; 𝑹𝑶𝑪: 𝑹𝑶𝑪𝒙𝟏 ∩ 𝑹𝑶𝑪𝒙𝟐 (14-1)

10. SAMPLE SHIFTING

𝒁[𝒙(𝒏 − 𝒏𝒐)] = 𝒛−𝒏𝒐 𝑿(𝒁), 𝑹𝑶𝑪 ∶ 𝑹𝑶𝑪𝒙 (14-2)

11. FREQUENCY SHIFTING

𝒛 (14-3)
𝒁[𝒂𝒏 𝒙(𝒏)] = 𝑿 ( ) =; 𝑹𝑶𝑪 ∶ 𝑹𝑶𝑪𝒙𝒔𝒄𝒂𝒍𝒆𝒅𝒃𝒚|𝒂|
𝒂

12. FOLDING

𝟏 (14-4)
𝒁[𝒙(−𝒏)] = 𝑿 ( ) =; 𝑹𝑶𝑪 ∶ 𝒊𝒏𝒗𝒆𝒓𝒕𝒆𝒅𝑹𝑶𝑪𝒙
𝒛

13. COMPLEX CONJUGATION

𝒁[𝒙∗ (𝒏)] = 𝑿∗ (𝒛∗ ); 𝑹𝑶𝑪 ∶ 𝑹𝑶𝑪𝒙 (14-5)

14. DIFFERENTIATION IN THE Z- DOMAIN

𝐝𝐗(𝐳) (14-6)
𝐙[𝐧𝐱(𝐧)] = −𝐳
𝐝𝐳

130
Signals And Systems Lab Manual EL-315

15. MULTIPLICATION

𝒁[𝒙𝟏(𝒏)𝒙𝟐(𝒏)] (14-7)
𝟏
= ∮ 𝑿𝟏(𝒗)𝑿𝟐(𝒛⁄𝒗)𝒗−𝟏 𝒅𝒗; 𝑹𝑶𝑪 ∶ 𝑹𝑶𝑪𝒙𝟏 ∩ 𝒊𝒏𝒕𝒆𝒓𝒕𝒆𝒅𝑹𝑶𝑪𝒙𝟐
𝟐𝝅𝒋
𝒄

16. CONVOLUTION

𝒁[𝒙𝟏(𝒏) ∗ 𝒙𝟐(𝒏)] = 𝑿𝟏(𝒛)𝑿𝟐(𝒛); 𝑹𝑶𝑪 ∶ 𝑹𝑶𝑪𝒙𝟏 ∩ 𝑹𝑶𝑪𝒙𝟐 (14-8)

131
Signals And Systems Lab Manual EL-315

LAB TASK

TASK 1:

syms z
f = 2*z/(z-2)^2;
T1=iztrans(f)

returns

ans =

ezplot(T1)

FIGURE 14-1

132
Signals And Systems Lab Manual EL-315

TASK 2:

syms n
g = n*(n+1)/(n^2+2*n+1);
T2=iztrans(g)

returns

ans =

ezplot(T2)

TASK 3:

As Linearity shows that

𝒁[𝒂𝟏𝒙𝟏(𝒏) + 𝒂𝟐𝒙𝟐(𝒏)] = 𝒂𝟏𝑿𝟏(𝒛) + 𝒂𝟐𝑿𝟐(𝒛)]; 𝑹𝑶𝑪: 𝑹𝑶𝑪𝒙𝟏 ∩ 𝑹𝑶𝑪𝒙𝟐

Same can be applied while computing the inverse z-transform

Then, take f, and g from task 1, and 2 and compute the given below

𝒊𝒏𝒗𝒆𝒓𝒔𝒆𝒁[𝟓𝒇 + 𝟏𝟎𝒈] = 𝟓𝑻𝟏 + 𝟏𝟎𝑻𝟐

TL3=iztrans([5 ∗ f + 10 ∗ g])

C=5*T1
D=10*T2

TR3= 5 ∗ T1 + 10 ∗ T2

133
Signals And Systems Lab Manual EL-315

TASK 4:

symsa z

>> T4=1/(1-1/4*z^-1)

T4 =

-1/(1/(4*z) - 1)

>>iztrans(h)

ans =

ezplot(T4)

TASK 5:

syms a z

if T4=1/(1-1/4*z^-1) , then find and show the result graphically using ezplot

 -zd(T4)/dz %time shifting property


 z^-7*T4 %time shifting property

-zd(T4)/dz =

z^-7*T4 =

134
Signals And Systems Lab Manual EL-315

TASK 6:

0.5 0.5
X(Z) = −1

1−z 1 − 0.333z −1

For the given problem find the inverse z-transfrom and write ur MATLAB code below

MATLAB CODE

135
Signals And Systems Lab Manual EL-315

LAB ASSIGNMENT

P1.
0.5
P(Z) =
1 − z −1

Find the following properties on X(Z) given below

 time shifting(𝒛−𝒏𝒐 𝑷(𝒁))at 𝒛−𝟗


 differentiation in z-domain , show result graphically
𝒛
 frequency shifting 𝑷 (𝒂) , a=5
𝟏
 folding𝑷 (𝒛 )

136
Signals And Systems Lab Manual EL-315

Observations/Comments/Explanation of Results:

Score of Student in this Lab: _________________________________________

Instructor’s Signatures with Date: _____________________________________

137
Signals And Systems Lab Manual EL-315

Questions:

1. Explain inverse Z-Transform.


2. Explain ‘iztrans(F)’.
3. Explain ‘iztrans(F,k)’.
4. Explain properties of Z-Transform.
5. What is region of convergence?
6. Explain Frequency shifting property.
7. Explain ‘syms’.
8. Explain sample shifting property.
9. Explain Folding property of Z Transform.
10. Explain Differentiation in the Z-domain.

138

Vous aimerez peut-être aussi