Sie sind auf Seite 1von 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

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) 2.7:Relations between LTI
system Properties (Open Ended) 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.

2
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

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

4
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:

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

6
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 = _______________________________

7
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

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

9
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

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

11
Signals And Systems Lab Manual EL-315

Observations/Comments/Explanation of Results:

Score of Student in this Lab: _________________________________________

Instructor’s Signatures with Date: _____________________________________

12
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?
11.

13
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 x a ( t ) in which the variablet represents time in seconds.

A discrete signal will be denoted byx (n)in which the variable nis integer and represents
discrete instances in time. It is also represented as

x ( n )={ x ( n ) }={… . , x (−1 ) , x ( 0 ) , x ( 1 ) , … } (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 x (n) would require
two vectors, one each for x and n .

BASIC SEQUENCES

UNIT SAMPLE SEQUENCE

δ [n]= 1 , n=0 (2-2)


{
0 , n≠ 0

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

δ [ n ] =u [ n ] −u[n−1] (2-3)

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

x [ n ] δ [ n ] =x [ 0 ] δ[n] (2-4)

This sampling property plays an important role in signal reconstruction.

UNIT STEP SEQUENCE

u[n]={ 1 , n≥ 0∧¿ 0 , n<0 (2-5)

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


u [ n ] = ∑ δ[n−m]
m=0
(2-6)

TOTAL ENERGY OF THE SIGNAL:


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

+∝
2
E ∝=∑ |x [ n ]| −∝ ≤n ≤+∝
−∝
(2-7)

TOTAL POWER OF THE SIGNAL:


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

+N
1 2
P ∝= lim ∑ |x [ n ]| −N ≤ n ≤+ N
N →∝ 2 N +1 −N (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

≫ Ex=∑ ( x .¿ conj ( x ) ) ; % forcomplexsequence


≫ Ex=∑ (|( x )|.¿ 2 ) % forrealsequence ;

SIGNAL POWER:

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


N −1
1 2
Px= ∑ |x [n ]|
N 0

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.
10
a. x 1 ( n )= ∑ ( m+1 ) [ δ ( n−2m )−δ ( n−2m−1 ) ] , 0 ≤ n≤ 25
m=0

b. x 2 ( n )=n2 [ u ( n+5 )−u ( n−6 ) ]+10 δ ( n )+ 20(0.5)n [u ( n−4 ) −u(n−10)]−25 ≤ n≤ 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

x [ n ] =C . e a .n (3-1)

Where “C“ and “a” are real . There are basically two types of behavior.
 If a is positive
As “n” increases “ x [ n ]” is growing exponential, a form that describes different physical
processes including chain reactions and complex chemical reactions.
 If a is negative
As “n” increases “ x [ n ]” 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 :

x [ n ] =e(σ + j w )n
0 (3-2)

As “ σ + j wo ” 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:

21
Signals And Systems Lab Manual EL-315

x [ n ] =cos ( wo n+θ ) (3-3)

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

x [ n ] =x [ n+ N ] ; ∀ n (3-4)

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

EVEN AND ODD SIGNALS


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

x [−n ] =x [ n ] (3-5)

Similarly the signal is referred to as odd if

x [−n ] =−x [ n ] (3-6)

22
Signals And Systems Lab Manual EL-315

LAB TASK

TASK1:REAL EXPONENTIAL SEQUENCE

n1
x 1 [n ]=( 0.9 ) ; 0 ≤n 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.

x 2 ( n ) =exp(2+3 i)n 2 ; 0 ≤n 2 ≤10

 Write its MATLAB code below


TASK3:SINUSOIDAL SEQUENCE

 Plot the following sequence.

π
(
x 3 [ n ]=3 cos 0 . 1 πn 3+
3 )
+2 sin(0 . 5 πn 3), 0 ≤ n 3≤ 10

TASK4: GENERATION OF COMPLEX VALUED EXPONENTIAL SEQUENCE

% Generation of a complex exponential sequence

clc;

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

22
Signals And Systems Lab Manual EL-315

K = 2;

n = 0:40;

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)

23
Signals And Systems Lab Manual EL-315

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

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

x ( n )=sin(n)e (−4 πn) , 0 ≤n ≤ 10

Show the result graphically.

24
Signals And Systems Lab Manual EL-315

Observations/Comments/Explanation of Results:

25
Signals And Systems Lab Manual EL-315

Score of Student in this Lab: _________________________________________

Instructor’s Signatures with Date: _____________________________________

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

x [ n−no ] (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 x [n] and
x [ n−no ]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

x [−n ] (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

27
Signals And Systems Lab Manual EL-315

x [ αn ] (4-3)

If we represent three signals x [ n ] , x [ 2 n ] , x [ 3 n ] , that are related by linear scale changes


in the independent variable. If we think of the example x [ n ] as tape recording, then
x [ 2 n ] 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 x 1 [ n ] and x 2 [ 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

x [ n ] =x [ n+ N ] ; ∀ n (4-4)

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

EVEN AND ODD SIGNALS


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

x [−n ] =x [ n ] (4-5)
Similarly the signal is referred to as odd if

x [−n ] =−x [ n ] (4-6)

The even part can be evaluated by the formula given below

EVEN {x [ n ] }=1 /2 [x [ n ] + x [ −n ] ] (4-7)

and for odd part the operatoin will be like

28
Signals And Systems Lab Manual EL-315

ODD {x [ n ] }=1/ 2[ x [ n ]−x [ −n ] ] (4-8)

29
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
x 1 [ n 1 ] = 1 ;1 ≤ n 1≤ 9
{ 0 ; otherwise
x 2 [ n 2 ] = 1; 3 ≤ n 2≤ 10
{ 0 ; otherwise
 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)

30
%
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 task 1 x 1 [ n ] and x 2 [ n ] using the function “sigmult”.

TASK 3: SCALING

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

α { x ( n ) } ={αx (n)} (4-9)

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

 Scale both the signals defined in task 1 x 1 [ n ] and x 2 [ n ] such that we get 2 x 1 [ n ] ,5 x 2 [ 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)”

y ( n )= { x ( n−k ) } (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;

 Using function “sigshift”, shift x 1 [ n ] in task 1 such that x 1 [ n−4 ].

31
TASK 5: FOLDING

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

y ( n )={ x(−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 task 1 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
x(n1) and x(n2).

n2 (4-12)
∑ x ( n )=x ( n1 ) +…+ x( n 2)
n=n 1

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

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

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

32
Using function “sum”, add samples of x 1 [ 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.
n2 (4-13)
∏ x ( n ) =x ( n 1) × … × x (n2 )
n 1

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

 Using function “prod”, multiply samples of x 1 [ n ] at 3,4,5 sample positions.


 Using function “prod”, multiply samples of x 1 [ n ] 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));

 Split the signal X1[n] obtained in the task 1 into its even and odd parts and show to the
instructor.

33
 Use stem function and plot ye , yo , and compare it to the y [ n ]

34
Signals And Systems Lab Manual EL-315

LAB ASSIGNMENT
P.1

Generate
x ( n )=e (− j 4 πn) , 0 ≤ n ≤10

y ( n )=e(−4 n) x ( n )+ x ( n−4 ) 0≤ n ≤ 10
Solve this by calling , signal add, signal shift functions, and show the result graphically.

P.2

Generate the complex-valued signal

x ( n )=e (−4 πn) , 0 ≤n ≤ 10

Plot its even and odd part, and show 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 x ( n )=e (− j 4 πn) , 0 ≤ n ≤10 in Matlab.
10. Explain function ‘Sigfold’.
11.

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

y ( n )=τ [ x(n)] (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.

L [ a 1 x 1 ( n ) + a2 x 2 ( n ) ] =a 1 L [ x 1 ( n ) ] +a 2 L [ x 2 ( n ) ] , ∀ a 1, a 2 , x 1 ( n ) , x 2(n) (5-2)

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


36
Signals And Systems Lab Manual EL-315

y ( n )=L [ x ( n ) ] =L¿ (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.

x (n)→ L [ . ] → y (n) → S h ift by


˙ k → y (n−k )

x (n)→ S h ift by
˙ k → x (n−k )→ L [ . ] → y (n−k )

∝ (5-4)
y ( n )=LTI [ x ( n ) ] = ∑ x ( x ) h(n−k )
k=−∝

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

x ( n ) → h ( n ) → y ( n ) =x ( n )∗h(n)

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.

∝ (5-5)
BIBOStability ⇔ ∑ |h(n)|<∝
−∝

37
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

h ( n ) =0 , n>0 (5-6)

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

N M (5-7)
∑ ak y ( n−k )= ∑ b m x ( n−m ) ,
k=0 m=0

∀ n a N ≠ 0 ,then thedifference equation isof 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=−∝¿ n=∝ . Therefore another form of the equation is

M N (5-8)
y ( n )= ∑ bm x ( n−m )−∑ ak y (n−k )
m =0 k =1

Solution to this problem can be obtained in the form

y ( n )= y h ( n ) + y p ( n) (5-9)

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

38
Signals And Systems Lab Manual EL-315

N
y h ( n ) =∑ c k z k n (5-10)
k=1

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

∑ ak z k (5-11)
0

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


zk satisfies the condition.

|z k|<1 , k =1, … … .. , N

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 equation :

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


a. Determine the stability of the system.
b. Determine and plot the impulse response of the system over 0 ≤ n ≤100.
c. 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.
11.

44
Signals And Systems Lab Manual EL-315

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


Ended)

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.

x [n]→ L [ . ] → y [n]→ S h ift by


˙ k → y [ n−k ]

x [n]→ S h i ft by
˙ k → x [n−k ]→ L [ . ] → y [n−k ]

∝ (6-1)
y [n]=LTI [ x [n] ] = ∑ x [ k ] h[n−k ]
k=−∝

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

x [n]→h [ n ] → y [n ]=x [n]∗h[n]

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)
L [ a1 x 1 ( t ) +a 2 x 2 ( t ) ]=a1 L [ x 1 ( t ) ]+ a2 L [ x 2 ( t ) ] , ∀ a 1 , a2 x 1 ( t ) , x 2 (t)

(6-3)
L [ a1 x 1 [n]+ a2 x 2 [n] ] =a1 L [ x 1 [n ]] +a2 L [ x 2 [n] ] , ∀ a 1 , a2 , x1 [n], x 2 [n]

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 δ [n−k ].
+∝ (6-4)
y [ n ] =∑ x [ k ] h [n−k ]=x [ n ]∗h[n]
−∝

CONTINUOUS-TIME LIT SYSTEMS: THE CONVOLUTION INTEGRAL


In case of continuous time it can be represented as

(6-5)
+∝
y ( t ) =∫ x ( k ) h ( t−k ) . dk=x ( t )∗h(t )
−∝

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)
x [ n ]∗h [ n ] =h [ n ]∗x [ n]=∑ x [ k ] h [n−k ]
−∝

And in continuous time

+∝ (6-7)
x ( t )∗h (t )=h ( t )∗x (t )=∫ x ( k ) h ( t−k ) . dk =¿
−∝

THE DISTRIBUTIVE PROPERTY

Convolution distributes over addition, so that in discrete time

(6-8)
x [ n ]∗( h1 [ n ] +h2 [ n ] ) =x [ n ]∗h1 [ n ] + x [ n ]∗h2 [ n ]

And in continuous time

(6-9)
x (t)∗( h1 ( t ) +h 2 ( t ) )=x (t)∗h1 (t)+ x (t)∗h2 (t)

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)
x [ n ]∗( h1 [ n ]∗h 2 [ n ] ) =( x [ n ]∗h1 [ n ] )∗h 2 [ n ]

Similarly in continuous time we get

(6-11)

47
Signals And Systems Lab Manual EL-315

x (t)∗( h1 ( t )∗h2 ( t ) ) =( x ( t )∗h1 ( t ) )∗h2 (t)

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

y [ n ] =( 2 x [ n ] −x 2 [n ]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.

n (6-12)
y [ n]= ∑ x [k ] % summer/accumulator
k=−∞

y [n]=x [n−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.

x [ n ] → SYSTEM → y [ n ] → INVERSE SYSTEM → x [ n ]

CAUSALITY AND STABILITY OF LTI SYSTEMS

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

48
Signals And Systems Lab Manual EL-315

(6-13)
h [n ]=0 , n> 0

STABILITY

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

(6-14)

BIBOStability ⇔ ∑|h[ n]|<∝
−∝

TIME INVARIANCE OF LTI SYSTEM

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

(6-15)
y ( t ) =k . x (t )
y ( t−¿ )=k . x (t−¿)

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 system is time variant or invariant.

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

TASK 3:

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


And h[n]=2 δ [ n+1 ] +2 δ [ n−1 ]

Compute and plot each of the following convolutions.

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

TASK 4:

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

50
Signals And Systems Lab Manual EL-315

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. h 1 [ n ] =( 5 )n u[3−n ]
1 n
b. h 2 [ n ] =n ()
3
u [n−1]

Write the MATLAB Code below for h1 and h2.

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

LAB ASSIGNMENT

P1.

51
Signals And Systems Lab Manual EL-315

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−2 j
t
a . h 1 ( t )=e u(t )

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

Observations/Comments/Explanation of Results:

52
Signals And Systems Lab Manual EL-315

Score of Student in this Lab: _________________________________________

Instructor’s Signatures with Date: _____________________________________

Questions:

1. What is linear system?


2. What is LTI system?
3. Explain different properties of LTI system.

53
Signals And Systems Lab Manual EL-315

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.

Lab-7: Continuous time convolution

Roll #:_____________________________

54
Signals And Systems Lab Manual EL-315

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:

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

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

55
Signals And Systems Lab Manual EL-315

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:

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

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

1
∫ 2
∗1
−2 π 1+ τ

1+(t−τ )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);

60
Signals And Systems Lab Manual EL-315

>> xlabel(‘t’);

>>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)
y [ n ] =x [ n ]∗h [ n ] = ∑ x [ k ] h[n−k ] = ∑ h [ k ] x [n−k ]
k=−∞ k=−∞

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.

69
Signals And Systems Lab Manual EL-315

PROBLEM WITH BUILT-IN CONV FUNCTION

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,

a0 ∞ 2 πnt 2 πnt (9-1)


2 n=1 (
x (t)= + ∑ an cos
T
+b n sin
T )
Where a0, an and bn are the Fourier series coefficients. These coefficients can be calculated by
applying the following equations:

T T
2 2 πnt 2 2 πnt (9-2)
a n= ∫ x (t) cos dt∧b n= ∫ x (t )sin dt
T 0 T T 0 T

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

+∞ T
( j 2 πnt/ T) 1 (− j 2 πnt /T )
x(t) = ∑ ❑cne with cn = ∫ x (t )e n = 0, 1, 2....
−∞ T 0

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,

a0 ∞ 2 πnt 2 πnt
x (t)=
2 n=1 n(
+ ∑ a cos
T
+b n sin
T )
and

80
Signals And Systems Lab Manual EL-315

T T
2 2 πnt 2 2 πnt
a n= ∫ x (t) cos dt ∧b n= ∫ x (t )sin dt
T 0 T T 0 T

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 n
x 1 (n)= n e , 0 ≤ n ≤25 , N =50
{ 026 ≤ n ≤ 49

And
−0.3 n
x 2 (n)= n e , 0 ≤ n ≤25 , N=100
{ 0 26 ≤n ≤ 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.3n
x ( n )= n e , 0≤ n ≤ 25 , N=50
{ 0 26 ≤ n≤ 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

+∞ +∞
− jωt 1 (10-1)
X(ω) = ∫ x ( t ) e dt ; x(t) = ∫ X ( ω)e jωt dω
−∞ 2 π −∞

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.

X ( jω ) =|X ( jω)|e j ≮ X ( jω) (11-1)

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


X ( jω )

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


X ( e jω )=|X ( jω)|e j ≮ X (e (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 Y ( jω ) of the
output of an LTI system is related to the transform X ( jω ) of the input to the system by the
equation below.

Y ( jω )= X ( jω ) H ( jω ) (11-3)

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


( jω ) :

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

Y ( e jω )= X ( e jω ) H ( e jω ) (11-4)

Thus the magnitude-phase notation of Eq.3 becomes

|Y ( jω)|=| X ( jω)|| H ( jω)|


≮ Y ( jω )=≮ X ( jω ) +≮ H ( jω)

Y ( jω ) m n (11-5)
H ( jω )= =∑ bk ( jω)k / ∑ ak ( jω)k
X ( jω ) k=0 k=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.

H ( jω )=e− jωto

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

|H ( jω)|=1 ,≮ H ( jω )=−ωto
The system with this frequency response characteristic produces an output that is simply a time
shift of the input.

y ( t ) =x( t−¿)

94
Signals And Systems Lab Manual EL-315

GROUP DELAY

In continuous-time, if ≮ H ( jω )= -ωto, then system imparts a time shift of –t o, 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

−d
τ ( ω )= |≮ H ( jω )|

LOG-MAGNITUDE AND BODE PLOTS

The phase relationship is additive, while the magnitude relationship involves the product of
|H ( jω)| and | X ( jω)|. 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

log |Y ( jω)|=log |H ( jω)|+ log| X ( jω)|

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 t −5 t − jωt
ifx ( t )=e u ( t ) , 0 ≤ t ≤ 10 find x ( jω )=∫ e e dt
0

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:

ifx ( t )=δ ( t ) , t h enfinditsfrequencyresponce , finditsgroup−delayandlogmagnitudevalueindecibles

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:

dy (t)
+10 y ( t )=x (t)
dx

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( + 2 πt)
4

d. cos ( π 62 t /10)

101
Signals And Systems Lab Manual EL-315

Observations/Comments/Explanation of Results:

Score of Student in this Lab: _________________________________________

102
Signals And Systems Lab Manual EL-315

Instructor’s Signatures with Date: _____________________________________

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


8. How will you write cos (π 62 t /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

104
Signals And Systems Lab Manual EL-315

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.

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+θ), −∞<t <+∞ (12-1)

xa ( t ) 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 πF

Hence we can rewrite as

xa(t) = Acos(2πFt+θ), −∞<t <+∞ (12-2)

The analog sinusoidal signal is characterized by the following properties.

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

105
Signals And Systems Lab Manual EL-315

xa(t+ Tp) = xa(t)

Where Tp= 1/F .


 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)
x ( n )= Acos ( ωn+θ ) ,−∞ <n<+ ∞

x ( n ) denotes an discrete 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 πf

Hence we can rewrite as

(12-4)
x ( n )= Acos ( 2 πfn+ θ ) ,−∞<n<+ ∞

The discrete sinusoidal signal is characterized by the following properties.

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


x ( n+ N )=x ( n ) foralln

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 π f 0 N =2 kπ
f 0=k /N

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

106
Signals And Systems Lab Manual EL-315

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


are identical.
 High rate of oscillation is attained when ω=πorω=−π

 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)
x ( n )=x a ( nT ) ,−∞< n<¿∞

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

n (12-6)
t=nT =
Fs

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.

x a ( t )= A cos(2πFt+θ) (12-7)

108
Signals And Systems Lab Manual EL-315

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

x a ( nT ) ≡ x ( n )= A cos(2πFt+θ) (12-8)
2 πnF
¿ A cos ( +θ)
Fs

x ( n )= Acos(ωn+θ) (12-9)

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

F
f= (12-10)
Fs
And,

ω=Ω T (12-11)

SAMPLING THEOREM

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

(12-12)

109
Signals And Systems Lab Manual EL-315

sin2 πBt
g(t )=
2 πBt

Thus xa(t) may be expressed as

n n (12-13)
x a (t)=∑ x a ( ) g(t− )
Fs Fs

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)
n sin 2 πB (t−n/2 B)
x a (t)=∑ x a ( ) ¿¿
2 B 2 πB(t−n/2 B)

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

LAB TASK

TASK 1:

x 1 ( t )=cos ⁡2 π (10)t
x 2 ( t )=cos ⁡2 π (50)t if Fs=40 Hz
find ing
a. x 1 ( n )
b. x 2 ( n )

Solution.:

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

110
Signals And Systems Lab Manual EL-315

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 xa ( t )=3 cos ⁡(300 πt) and Fs =700 , then find ω and f 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);
» stem(n,xn1);hold on
» t=-10:0.1:10;
» xt=cos(t);
» plot(t,xt,'r');hold off

111
Signals And Systems Lab Manual EL-315

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

xlabel('time in seconds');

ylabel('x(t)');

112
Signals And Systems Lab Manual EL-315

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;

plot(n3,xn3);

xlabel('n');

113
Signals And Systems Lab Manual EL-315

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

TASK 6:

114
Signals And Systems Lab Manual EL-315

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

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

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

115
Signals And Systems Lab Manual EL-315

axis([0 20 -2 2]);

hold;

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

plot(t,x_recon);

hold off;

waitforbuttonpress;

end

116
LAB ASSIGNMENT

P.1

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

e. cos ⁡( π 30 n/105)

f. sin( π 62 n/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. x ( n )=3 cos (5 t+ π /6)


b. x ( n )=cos ⁡(n /8) cos ⁡(πn/8)

P.3

Consider an analog signal given below

xa ( t )=3 cos ( 2000 πt ) +5 cos ( 6000 πt ) +10 cos ⁡(12000 πt)

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
Observations/Comments/Explanation of Results:

Score of Student in this Lab: ___________________________________________

Instructor’s Signatures with Date: _______________________________________

118
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 x ( n )=3 cos (5 t+ π /6)

119
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 (e jw ). 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)
X ( z )=Z [ x ( n ) ] = ∑ x ( n ) z−n
n=−∝

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|< Rx+¿

PROPERTIES OF THE Z-TRANSFORM

1. LINEARITY

120
Z [ a 1 x 1 ( n ) +a 2 x 2 ( n ) ] =a 1 X 1 ( z ) +a 2 X 2( z) ¿ ; ROC : ROCx 1 ∩ ROCx 2 (13-2)

2. SAMPLE SHIFTING

Z [ x ( n−no ) ] =z−no X ( Z ) , ROC :ROCx (13-3)

3. FREQUENCY SHIFTING

Z [ a n x ( n ) ]= X ( az )=; ROC : ROCxscaledby|a| (13-4)

4. FOLDING

Z [ x (−n ) ] =X ( 1z )=; ROC : invertedROCx (13-5)

5. COMPLEX CONJUGATION

Z [ x ¿ ( n ) ] = X ¿ ( z ¿ ) ; ROC : ROCx (13-6)

6. DIFFERENTIATION IN THE Z- DOMAIN

dX ( z) (13-
Z [ nx ( n ) ] =−z
dz 7)

121
7. MULTIPLICATION

1 z −1 (13-8)
Z [ x 1 ( n ) x 2 ( n ) ]= ∮
2 πj c ()
X 1 (v ) X 2
v
v dv ; ROC : ROCx 1 ∩intertedROCx 2

8. CONVOLUTION

Z [ x 1 ( n )∗x 2 ( n ) ]= X 1 ( z ) X 2 ( z ) ; ROC : ROCx 1∩ ROCx 2 (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
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−1.

z
X ( Z )= 2
3 z −4 z+ 1
Solution.
First rearrange X(Z) so that it is a function in ascending powers of z−1 .
z−1
X Z=
( )
3−4 z−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.333 z −1

123
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
3 z−1 z
x ( z )= = = 2
4 1 −1 −2
1− z−1 + z−2 3−4 z + 1 z 3 z −4 z +1
3 3

Now applying the same procedure determine inverse z-transform of

1
x ( z )= 2
( 1−0.9 z −1 ) (1+ 0.9 z−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 )= 2
3 z −4 z+ 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
>>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
LAB ASSIGNMENT

P1. For the given signal plot the pole-zero plot given below and write its code.

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

126
Observations/Comments/Explanation of Results:

Score of Student in this Lab: _________________________________________

Instructor’s Signatures with Date: _____________________________________

127
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. Explain ’roots’.

LAB-14: Inverse z-transform on Matlab

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

PROPERTIES OF THE Z-TRANSFORM

129
9. LINEARITY

Z [ a 1 x 1 ( n ) +a 2 x 2 ( n ) ] =a 1 X 1 ( z ) +a 2 X 2( z) ¿ ; ROC : ROCx 1 ∩ ROCx 2 (14-1)

10. SAMPLE SHIFTING

Z [ x ( n−no ) ] =z−no X ( Z ) , ROC :ROCx (14-2)

11. FREQUENCY SHIFTING

Z [ a n x ( n ) ]= X ( az )=; ROC : ROCxscaledby|a| (14-3)

12. FOLDING

1 (14-4)
Z [ x (−n ) ] =X ()
z
=; ROC : invertedROCx

13. COMPLEX CONJUGATION

Z [ x ¿ ( n ) ] = X ¿ ( z ¿ ) ; ROC : ROCx (14-5)

14. DIFFERENTIATION IN THE Z- DOMAIN

130
dX ( z) (14-
Z [ nx ( n ) ] =−z
dz 6)

15. MULTIPLICATION

1 z −1 (14-7)
Z [ x 1 ( n ) x 2 ( n ) ]= ∮
2 πj c ()
X 1 (v ) X 2
v
v dv ; ROC : ROCx 1 ∩intertedROCx 2

16. CONVOLUTION

Z [ x 1 ( n )∗x 2 ( n ) ]= X 1 ( z ) X 2 ( z ) ; ROC : ROCx 1∩ ROCx 2 (14-8)

131
LAB TASK

TASK 1:

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

returns

ans =

ezplot(T1)

FIGURE 14-1

132
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

Z [ a 1 x 1 ( n ) +a 2 x 2 ( n ) ] =a 1 X 1 ( z ) +a 2 X 2( z) ¿ ; ROC : ROCx 1 ∩ ROCx 2

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

inverseZ [ 5 f +10 g ] =5 T 1+10T 2

TL3=iztrans¿)

C=5*T1
D=10*T2

TR3=5∗T 1+10∗T 2

133
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 =

TASK 6:

134
0.5 0.5
X ( Z )= −1

1−z 1−0.333 z −1

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

MATLAB CODE

LAB ASSIGNMENT

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

Find the following properties on X ( Z ) given below

 time shifting( z−no P ( Z ))at z−9


 differentiation in z-domain , show result graphically
z
 frequency shifting P () a
, a=5

 folding P ( 1z )

Observations/Comments/Explanation of Results:

136
Score of Student in this Lab: _________________________________________

Instructor’s Signatures with Date: _____________________________________

Questions:

1. Explain inverse Z-Transform.


2. Explain ‘iztrans(F)’.
3. Explain ‘iztrans(F,k)’.
4. Explain properties of Z-Transform.

137
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