Vous êtes sur la page 1sur 76

Lab Manual

SIGNAL AND SYSTEMS


EE 312







School of Science and Technology


University of Management and Technology
CII, 1ohar Town Lahore
http:/www.umt.edu.pk


LL312 SIGNAL AND SS1LMS LA8


L|st Cf Lxper|ments

NC Lxper|ments

1
lnLroducLlon Lo slngal and sysLems and generaLlng baslc slgnals
leunlL sLep unlL lmpulse power and energy slgnals

2 CeneraLlng dlfferenL Lypes of slgnals and Lhelr operaLlons

3
CeLLlng famlllar wlLh sysLems and Lhelr classlflcaLlons lmpulse
and sLep response of Lhe sysLems

4
lnLroducLlon Lo Lhe conLlnuous Llme convoluLlon and flndlng
ConvoluLlon of dlfferenL Lypes of conLlnuous slgnals


3
lnLroducLlon Lo Lhe dlscreLe Llme convoluLlon and flndlng
ConvoluLlon of dlfferenL Lypes of conLlnuous slgnals uslng bullLln
And user deflned convoluLlon funcLlon

6 CeLLlng famlllar wlLh lourler serles and ploLLlng magnlLude and
hase response of Lhe perlodlc slgnals

CeLLlng famlllar wlLh lourler Lransform and lnverse lourler
1ransforms of varlous slgnals
8
llndlng ZLransform uslng parLlal fracLlon meLhod ln MA1LA8
and ploLLlng olesZeros Lo flnd Lhe sysLems SLablllLy
9
SysLems represenLaLlons ln Zdomaln and flndlng Lhe soluLlon
of dlfference equaLlons and Lhelr frequency response uslng Z
Lransform

10
CeLLlng famlllar wlLh Laplace Lransforms llndlng sLep and
lmpulse response uslng Lransfer funcLlon and ploLLlng Lhe
8odeploL ln MA1LA8
11
CeLLlng famlllar wlLh lnverse Laplace Lransforms ln
MA1LA8












EL-312 SIGNALS AND SYSTEMS
LAB 01
PRE-LAB

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
u
() in which the variable represents
time in seconds.
A discrete signal will be denoted by (n) in which the variable n is integer and
represents discrete instances in time. It is also represented as
x() = {x()] = {.. , x(-1), x(), x(1), .] (1)

here 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 doesnt have any information about sample position
n. Therefore a correct representation of (n) would require two vectors, one
each for and n .
BASIC SEQUENCES
UNIT SAMPLE SEQUENCE


6() = { 1 , = }
, =


{.. , , , , 1, , .]



(2)



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



Figure1: Discrete-Unit sample (impulse)

Similarly unit sample can be expressed as the first difference of the unit
step.
6|] = u|] -u| - 1] (3)


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

(4)
This sampling property plays an important role in signal reconstruction.
UNIT STEP SEQUENCE

u() = { 1 , }
, <


(5)

{.. , , , , 1, 1, 1.]

%n)
n



u (n) 1 . . . . .



n

Figure 2: Discreet 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.

|n] = o|]
n
m=-



(6)

TOTAL ENERGY OF THE SINGAL:
If |n] is our discrete time signal then. Its total energy will be

= |x|]|
2
+
-
- +


(7)

TOTAL POWER OF THE SINGAL:
If |n] is our discrete time signal then. Its total power will be

P =
N-
1
2N+1
|x|]|
2
+N
-N
- N +N


(8)
0 1 2 3 4
LAB TASK
Note: make m-file, show function's polt,xlable,ylable,hold,stem and
observe the output and show to the instrutor, see MATLAB help.

UNIT IMPULSE IMPLEMENTATION
function x,n,=impseq(n0,n1,n2)
%Generate x(n) = delta(n-n0); n1 nn2
%---------------------------------------------------
%x,n,=impseq(n0,n1,n2)
n=n1:n2,; x= (n-no)== 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-no) = 0,;

SIGNAL ENERGY IMPLEMENTATION
Jhere Lhe superscrlpL #&# denoLes Lhe operaLlon of complex con[ugaLlon 1he energy of a flnlLe
duraLlon sequence x%n) can be compuLed ln MA1LA8 uslng
x = u(x.
-
(x)); % ex euee
x = u((x).

2) % e euee;
SINGAL POWER:

1he average power of a perlodlc sequence wlLh fundamenLal perlod n ls glven by
Px =
1
N
_ |x()|
2 N-1




age | 8

LAB ASSIGNMENT
ive title to the graph , label x-axis, 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.
a.
1
(n) = _ ( +)|o(n - ) - o(n - -)], n
10
m=0

b.
2
(n) = n
2
|(n +) -(n -)] + o(n) +(.)
n
|(n -) - (n - )]
- n

Hint: See Matlab help for "stem" function

P.2
Let x(n) = {1,-2,4,6,-5, 8,10} . Generate and plot the samples of the
- n l
following sequences.
a. (n) = _ n(n - )
5
k=1

b. (n) = (n +) +(n -) -(n)






age | 9

EL-312 SIGNALS AND SYSTEMS
LAB 02
PRE-LAB
TYPES OF SEQUENCES
REAL VALUED EXPONENTIAL SEQUENCE

x|] = C . e
.
(1)

here " " and "o are real . There are basically two types of behavior.
If a is positive
As "n increases " |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 "|n] is decaying exponential, a from that describes the radioactive
decay, RC circuits and damped mechanical systems.

COMPLEX VALUED EXPONENTIAL SEQUENCE
Complex exponential signal is defined as :

x|] = e
(o+w

)
(2)

As " o +w

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

x|] = (w

+0) (3)

RANDOM SINGALS
Many practical signals cant 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.
O RAND(1,N)
It generates a length N random sequences whose elements are uniformly distributed
between [0,1].
O RANDN(1,N)


age | 10

It generates a length N aussian random sequence with mean 0, and varience 1.

PERIODIC SEQUENCE
A sequence x|] is periodic if
x|] = x| +N]; v (4)

The smallest integer that satisfies the above relation is called the fundamental period.
EVEN AND ODD SIGNALS
x|] is an even signal if it is identical to its time-reversal counterpart i.e.
x|-] = x|] (5)

Similarly the signal is referred to as odd if
x|-] = -x|] (6)


age | 11

LAB TASK

TASK1: REAL EXPONENTIAL SEQUENCE
(n) = (.9)
n
; n
n = 0:10,;
x = (0.9).^n;

!lot " x(n).
Label x-axis and y-axis.
Also give title to the graph.

TASK2: COMPLEX VALUED EXPONENTIAL SEQUENCE

!lot the following sequence.

x() = ex(2 +3|); 1

JrlLe lLs MA1LA8 code below

TASK3: SINUSOIDAL SEQUENCE
!lot the following sequence.
x|] = 3 . 1a +
a
3
+ 2|(. 5a), 1
JrlLe lLs MA1LA8 code below

TASK4: SIGNAL ADDITION.
Signal addition is implemented in MATLAB by using the arithmetic operator "+. However,
the length of x
1
(n) and x
2
(n) must be same. If sequences are of unequal length, or if the
sample positions are different for equal length sequences; then we cant 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)
%yy,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)


age | 12

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
enerate x1 and x2 using impseq function (Refer to Lab 01) given below
x
1
|1] =
1; 1 1 9
; thew|e


x
2
|2] =
1; 3 2 1
; thew|e


Add x
1
[n] and x
2
[n] using function "sigadd.

TASK 5: SIGNAL MULTIPLICATION.
Signal multiplication is implemented in MATLAB by using the array operator ".*. However,
the length of x
1
(n) and x
2
(n) must be same. If sequences are of unequal length, or if the
sample positions are different for equal length sequences; then we cant 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)
%-------------------------------------------
%yy,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)
%
n=min(min(n1),min(n2)):max(max(n1), max(n2)); % duration of y(n)
y1=zeros(1,length(n)); y2=y1; % initiallization
y1(find((n=min(n1))&(n<=max(n1))==1))=x1;
y2(find((n=min(n2))&(n<=max(n2))==1))=x2;
y=y1.y2;
end

Multiply both the signals defined in task4 x
1
|] and x
2
|] using the above function
"sigmult

TASK 6: SCALING
In this operation each sample is multiplied by a scalar .

{()] = {()]

(10)
An arithmetic operator "* is used to implement the scaling operation In MATLAB.


age | 13

Scale both the signals defined in task4 x
1
|] and x
2
|] such that we get 2x
1
|] ,x
2
|].
show the results to the instructor.


TASK 7: SHIFTING
In this each sample of "x(n) is shifted by an amount "k to obtain a shifted sequence "y(n)

Y() = {x( -)]

(11)
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
|] task4 such that x
1
| -4].


TASK 8: FOLDING
In this operation each sample of "x(n) is flipped around n=0, to obtain a folded sequence
"y(n)
Y() = {x(-)] (12)

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 |] , and show to the instructor.




age | 14

TASK 9: SAMPLE SUMMATION.

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

() = (1) ++(2)
2
=1


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



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

Using function "sum, add samples of x
1
|] at 2,3,4, sample positions.
Using function "sum, add samples of x
1
|] at 7,8,9,10 sample positions.
hat result you have concluded from the functions "sigadd and "sum




TASK 10: SAMPLE PRODUCTS
This operation also differs from the singal multiplication operation. It multiplies all sample
values of x(n) between n1 and n2.
() = (
1
) . (
2
)

1



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

Using function "prod, multiply samples of x
1
|] at 3,4, sample positions.
Using function "prod, multiply samples of x
1
|] at 8,9,10 sample positions.
hat result you have concluded from the functions "sigmult and "prod


TASK 11: EVEN AND ODD SYNTHESIS
function xe, xo, m,= evenodd(x,n)
%Real signal decomposition into even and odd parts


age | 13

%------------------------------------------------------------------
%xe,xo,m,= evenodd(x,n)
%
If any(img(x) ~= 0)
Error (`x is not a real sequence')
and

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

Splirt the signal obtained in the task Y|] into its even and odd parts and show to the
instructor.
Use stem function and plot ye,yo , and compare it to the Y|]



age | 16

LAB ASSIGNMENT
P.1
enerate and plot U[_(.n) , - n .Is this sequence periodic? If it is what is its
fundamental period? From the examination of the plot, what interpretation can you give to
integers K and N. above.

P.2
enerate the complex-valued signal

x() = e
(-.1+.3)
, 1

And plot its magnitude, phase , the real part, and the imaginary part in four separate
subplots. (see MATLAB help for subplot).






















age | 1

EE-312 SIGNALS AND SYSTEMS
LAB 03 (SYSTEMS)
PRE-LAB
INTRODUCTION
A system is a collection of elements or components that are organized for a common
purpose. !hysical systems in the broad sense are an interconnection of components, devices
or subsystems.
1. CONTINUOUS-TIME SYSTEM
A system in which continuous-time signals are applied and result in continuous-time output,
such a system has () on () as input and output respectively.
2. DISCRETE-TIME SYSTEM
A discrete-time system is described as an operator 1| . ] that takes a sequence x(n) called
excitation and transforms it into another sequence y(n) called response. i.e
Y() = z| x()] (1)

CLASSIFICATION
LINEAR SYSTEM
A discrete system 1| . ] is a linear if and only if L| . ] satisfies the principle of superposition
as shown in Eq. 2.
|1x1() + 2x2()] = 1|x1()] + 2 |x2()], v1, 2, x1(), x2() (2)

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

Y() = | x()] = | x()6( - )

=-
= x()( -)

=-

(3)

H(n - ) is called the response of linear system , called the impulse response.




LINEAR TIME-INVARIANT (LTI) SYSTEM


age | 18

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 H| . ] and shifting operators are
reversible as shown below.

(n) - H| . ] - (n) - b

- (n -)

(n) - b

- (n - ) - H| . ] - (n -)

Y() = |x()] = x(x)h( -)

=-

(4)


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

(n) - (n) - (n) = (n) - (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.

|(n)| <= |(n)| <, v,
Note: An LTI system is BIBO stable if and only if its impulse response is absolutely
summable.

VVW St||tY = |h()| <

-

(5)


CAUSALITY
A system is said to be causal if the output at index "n
o
depends only on the input up to and
including the index "n
o
i.e. the output doesnt depend on the future values of the input. An
LTI system is causal if and only if the impulse response


h() = , > (6)



age | 19



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

Y( -) = x( -),

=
N
=

(7)


v aN = , then the uiffeienUe equati[n i_ [f [iuei N.

This equation describes the recursive approach for computing the current output ,
given the input values and previously computed output values. In practive this
equation is computed forward in time , from n = - t[ n = . Therefore another form
of the equation is

Y() = x( - ) -Y( -)
N
=1

=

(8)


Solution to this problem can be obtained in the form
Y() = Y() +YP() (9)




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

Y() = z

N
=1


(10)


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

z



(11)


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

|zk| < , = , ... . ,


age | 20




LAB TASK

Note: make m-file, show functions polt,xlable,ylable,hold,stem and observe the output and
show to the instrutor, 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
= filtei (b, a, )
here
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 be zero.
1. (n) -(n - ) + .9(n - ) = (n), vn
a. Calculate and plot the impulse response h(n) at n= -20, .., 100.
b. Calculate and plot the unit step response _(n) at n= -20, .., 100.
c. Is the system specified by h(n) stable?

TASK1. MATALB SCRIPT FOR IMPULSE RESPONCE
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);titile (`impulse responce'); xlable(`n');
ylable(`h(n)')



age | 21


Note: see impseq function in previous lab manuals

TASK2. MATALB SCRIPT FOR STEP RESPONCE


x = stepseq(0 , -20, 120);
s=filter(b,a,x);
subplot(2,1,2); stem(n,s);
titile (`step responce'); xlabel(`n'); ylabel(`s(n)')


Note: see stepseq function in previous lab manuals



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

hich implies that the system is stable. An alternate approach is to use the matlab
stability condition using MATLABs root function.

z = i[[t_(a);
agz = ab_(z)
Nagz = .98
.98

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



age | 22


LAB ASSIGNMENT

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

(n) - .(n - ) + .(n -) = (n) + (n -) +(n -)
a. Determine the stability of the system.
b. Determine and plot the impulse response of the system ove n . Determine
the stability from this impulse response.





























age | 23

EL-312 SIGNALS AND SYSTEMS
LAB 4 (CONTINUOUS TIME CONVOLUTION)
PRE-LAB
INTRODUCTION

In this lab we will study continuous time convolution. Again defining convolution that
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) y(t)


Fig.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:

() = () - () = ] ()( -)

-
= ] ()( -)

-
(1)

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


h(t)


age | 24

STEPS TO CARRY OUT CONTINUOUS TIME CONVOLUTION

Continuous time convolution is very much similar to discrete time convolution. Basic points
to carry out the convolution are bulleted below:
O Assume input x(t) and impulse response h(t) are available.
O Change the variable from t to of input and impulse response.
O Flip h() to make it h(-). (e can reverse either x() or h() on our choice).
O 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()
O Slide h(t - ) to the right over x() region by region.
O Multiply the overlapping areas of regions and perform the integration.
O Carry on this process unless h(t - ) slides past all of x().
O 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:

Fig.2
The impulse response is given by:


age | 23

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


Fig.4




age | 26

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:

() = () - () = ] ()( -)

-
= ] ()( -)

-
(2)

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





TASK 1:

age | 2

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 on an example regarding continuous time convolution:
Let us consider the convolution of 1/(1+t2) with itself. That is let us calculate


+
2
2n
-2n
-

+( - )
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,-2pi,2pi);

age | 28

subplot(2,1,1);
ezplot(f);
xlabel(`t');
ylabel(`f');
grid on;
title(`original signal ');
subplot(2,1,2);
ezplot(z);
xlabel(`t');
ylabel(`z');
grid on;
title(`continuous convolution ');

The function should look like this:


Fig.

age | 29

and the convolution result is:

Fig.6





TASK#3
Consider the input
x(t) = [1 - e-1.t] 0t10
and the impulse response be
h(t) = [2te-t - e-3t] 0t10
and the output is defined as
y(t) = x(t) * h(t)
You are required to:
O rite the MATLAB code to find y(t).
O !lot x(t), h(t) and y(t) in one window. (Hint: Use subplot).

age | 30

O Label x-axis of all three graphs as t.
O Label y-axis of x(t), h(t) and y(t) as Input x(t), Impulse Response h(t) and Output
y(t) respectively.
O Apply grid on all three graphs.
O ive the title Convolution to all three graphs.

TASK#4
Consider the input
x(t) = cose(t)
and the impulse response be
h(t) = sin(t) 0t8
and the output is defined as
y(t) = x(t) * h(t)
You are required to:
O rite the MATLAB code to find y(t).
O !lot x(t), h(t) and y(t) in one window. (Hint: Use subplot).
O Label x-axis of all three graphs as t.
O Label y-axis of x(t), h(t) and y(t) as Input x(t), Impulse Response h(t) and Output
y(t) respectively.
O Apply grid on all three graphs.
O ive the title Convolution to all three graphs.
TASK#5

Consider the input
x(t) = cos(t)+t 0t6
and the impulse response be
h(t) = sin(t)+e^2t 0t8
and the output is defined as
y(t) = x(t) * h(t)
You are required to:
O rite the MATLAB code to find y(t).
O !lot x(t), h(t) and y(t) in one window. (Hint: Use subplot).
O Label x-axis of all three graphs as t.

age | 31

O Label y-axis of x(t), h(t) and y(t) as Input x(t), Impulse Response h(t) and Output
y(t) respectively.
O Apply grid on all three graphs.
O ive the title Convolution to all three graphs.

age | 32

LAB ASSIGNMENTS

Task#1
Consider the input
x(t) = e
-0.t
0t10
and the impulse response be
h(t) = cos(t) 0t10
and the output is defined as
y(t) = x(t) * h(t)
You are required to:
O rite the MATLAB code to find y(t).
O !lot x(t), h(t) and y(t) in one window. (Hint: Use subplot).
O Label x-axis of all three graphs as t.
O Label y-axis of x(t), h(t) and y(t) as Input x(t), Impulse Response h(t) and Output
y(t) respectively.
O Apply grid on all three graphs.
O ive the title Convolution to all three graphs.










age | 33



EL-312 SIGNALS AND SYSTEMS
LAB 5(DISCRETE TIME CONVOLUTION)
PRE-LAB
INTRODUCTION

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:


x[n] y[n]


Fig.1
The out put y[n] will be the convolution of input x[n] and impulse response of the system
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:

(t) = (t) - h(t) = ] ()h(t -)u

-
= ] h()(t -)u

-
(1)

2. DISCRETE TIME
h[n]

age | 34


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

|n] = |n] - |n] = _ |]|n - ]

k=-
= _ |]|n - ]

k=-
(2)

STEPS TO CARRY OUT CONVOLUTION

Convolution is a step-by-step procedure. Basic points to carry out the convolution are
bulleted below:
O Assume input x[n] and impulse response h[n] are available.
O Change the variable from n to k of impulse response i.e. h[n] h[k].
O Flip h[k] to make it h[-k]. (e can reverse either x[n] or h[n] on our choice).
O Shift h[k] to the left by n i.e. make it h[n-k].
O Slide h[n-k] to the right over x[n] index by index.
O Multiply the overlapping weights of indices and calculate the sum.
O Carry on this process unless h[n-k] slides past all of x[n].
O 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:

age | 33


Fig.2
The impulse response is given by:


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


age | 36

PRE-LAB TASK

Solve the above mentioned example mathematically (graphically) and bring it solved before
the lab.









age | 3

LAB TASK

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

TASK1: CONV FUNCTION

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

x = [3,11,7,0,-1,4,2];
h = [2,3,0,-5,2,1];
y = conv(x,h)

y =

6 31 47 6 -51 -5 41 18 -22 -3 8 2
This convolution functions proves to be very useful but it misses one of the most important
things of convolution which is discussed below.

PROBLEM WITH BUILT-IN CONV FUNCTION

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. hat is required is the beginning and end point of y[n]. iven finite duration x[n]
and h[n], it is easy to determine these points. Let
{x[n]; n
xb
5 n 5 n
xe
}

age | 38

And
{h[n]; n
hb
5 n 5 n
he
}
be the two finite duration sequences, then starting and end points of y[n] can be written as
n
yb
= n
xb
+ n
hb
and n
ye
= n
xe
+n
he

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

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: EXAMPLE
x = [3,11,7,0,-1,4,2];

age | 39

nx = [-3:3];
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. e can plot this y[n] by the commands:

stem(ny,y);
xlabel('n');
ylabel('y[n]');
title('Convolution');

The output should be like this:



Fig.
TASK#4

age | 40


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 are taken to be the same for the sake of simplicity. e
define output as the convolution of input and impulse response.
y[n] = x[n] * h[n].
You are requied to:
O rite the MATLAB code to find y[n].
O !lot x[n], h[n] and y[n] in one window. (Hint: Use subplot).
O Label x-axis of all three graphs as n.
O Label y-axis of x[n], h[n] and y[n] as Input x[n], Impulse Response h[n] and Output
y[n] respectively.
O Apply grid on all three graphs.
O ive the title Convolution to all three graphs.

TASK#5

Consider the input signal
x[n] = 1, 0 n 4
0, otherwise
and the impulse response of the system as
h[n] = 0.n, 0 n 6
0, otherwise
then the output will be
y[n] = x[n] * h[n]
You are required to:
O rite the MATLAB code to find y[n].
O !lot x[n], h[n] and y[n] in one window. (Hint: Use subplot).
O Label x-axis of all three graphs as n.

age | 41

O Label y-axis of x[n], h[n] and y[n] as Input x[n], Impulse Response h[n] and Output
y[n] respectively.
O Apply grid on all three graphs.
O ive the title Convolution to all three graphs.








age | 42

LAB ASSIGNMENTS

TASK#1

hen the convolution of a signal is performed with itself, it is called correlation which is
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, -2n0
-1, 0n2
You are required to:
O rite the MATLAB code to find y[n].
O !lot x[n] and y[n] in one window. (Hint: Use subplot).
O Label x-axis of both graphs as n.
O Label y-axis of x[n] and y[n] as Input x[n] and Output y[n] respectively.
O Apply grid on all three graphs.
O ive the title Convolution to both the graphs.





















age | 43

EL-312 SIGNALS AND SYSTEMS
LAB 06
PRE-LAB

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
ascommunications and signal processing. These representations are among the most
powerful andmost common methods of analyzing and understanding signals. A solid
understanding of Fourierseries and the Fourier transform is critical to the design of filters
and is beneficial inunderstanding 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,

x(t) =

2
+ _

s
2at

s
2at

]
m
=1

(1)


where,

, ,
n
and b
n
are the Fourier series coefficients. These coefficients can be calculated
byapplying the following equations:

=
2

x(t)

s
2at

dt d

=
2

x(t)

s
2at

dt

(2)


If the Fourier coefficients are written as a single complex number c
n
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


x(t) = _
+
-
c
n

(]2nnt1)
with c
n
=
1
1
] ()
1
0

(-]2nnt1)
n = 0, 1, 2....




age | 44

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 = xxxx,; % 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 , ) ;


Figure 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 = n,;
mag_an = a0 mag_an,; % including a0 with a_n;
phase_an = ph0 phase_an,;

age | 43

figure (2);
clf;
subplot (2, 1 , 1);
plot (n, mag_an, `o');

grid;
xlabel( ` Harmonic Number');
ylabel (`Magnitude');
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 2


TASK3.

function Xk,=dfs(xn,N)
%computes discrete fourier series coefficients
n=0:1:N-1,;
k=0:1:N-1,;
WN=exp(-j2pi/N);
nk=n'k;
WNnk=WN.^nk;
Xk=xnWNnk;
end




age | 46

Consider signals given below
X1(n) = [2,0,2,0] N=4;
and
x2(n) = [2,0,2,0] N=4;
You are required to:
O rite the MATLAB code given above for DFS and calculate Xk;
O stem x1(n), x2(n) and Xk1(n) and Xk2(n)in one window. (Hint: Use subplot).
O Label x-axis of all three graphs as n
O Label y-axis of x1(n), x2(n) and Xk1(n) and Xk2(n) respectively.
O Apply grid on all three graphs.
ive the title to all four graphs


TASK4.
As by definition ,




() =
o
0

+_o
n
U[_
nn

+b
n
_in
nn

n=1

and

o
n
=

()
1
0
U[_
nn

ut anu b
n
=

()
1
0
_in
nn

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













age | 4


LAB ASSIGNMENT


Consider signals given below
(n) = _
n
-0.3n
, n
n 9

, =
And
(n) = _
n
-0.3n
, n
n 99

, =

You are required to:
O Call DFS function used in TASK3 and calculate Xk1,and Xk2;
O stem x1(n), x2(n) and Xk1(n) and Xk2(n)in one window. (Hint: Use subplot).
O Label x-axis of all three graphs as n
O Label y-axis of x1(n), x2(n) and Xk1(n) and Xk2(n) respectively.
O Apply grid on all three graphs.
ive the title to all four graphs





















age | 48



EL-312 SIGNALS AND SYSTEMS
LAB 07
PRE-LAB

FOURIER TRANSFORM


e 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






MATLAB used the fourier and ifourier functions to transform expressions between
domains.
x(t) <--> X(w)
>>help fourier
>>help ifourier


LAB TASK
TASK1.

MATLAB uses a w to represent in symbolic expressions.


doc fourier
Write about `fourier 'what you have understood.



X() = ] x(t)e
-mt
+m
-
dt ; x(t) =
1
2a
] (m)
+m
-
e
mt
d
(1)

age | 49




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


f1 = fourier(x) %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 :(t) and/or impulse function (t).

Consider the signal
X2 (t) = -e
- t
:(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

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





age | 30

TASK 3.

Sgn (t) < 2/j w

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

f3 = fourier (x3) %hit enter

f3 =

ezplot (abs(f3))

Figure 1
ezplot ( abs (f3) , -10 10, )

Figure 2

age | 31


syms w
ezplot ( w , abs ( f3) , -5 5 -10 10 , )

Figure 3
axis ( -5 5 -10 10 , );

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



age | 32



LAB ASSIGNMENT
P1.
Plot the fourier and its inverse transforms of: e
- at
u (t).







































age | 33


EL-312 SIGNALS AND SYSTEMS
Z-transform LAB 8
PRE-LAB
THE Z-TRANSFORM

As the discrete-fourier transform approches for representing discrete signals using
complex exponential sequences. And it has advantages for LTI systems becouse it describes
systems in the frequency domain using frequency response function (e
jw
). However, there
are two shortcomings to the fourier transform approach.First, there are many useful signals
in practice such as u(n) and nu(n) for which the discrete-time foureir tarnsform does not
exit. Second , 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 (n) is given by
() = |()] = ()

=-

-

(1)


here "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

- < |z| < +

PROPERTIES OF THE Z-TRANSFORM

. LINEAITY
|1x1() +2x2()] = 11(z) +22(z)]; RWC: RWCx1 r RWCx2

(2)



age | 34

2. ANPLE IFTINu
|x(- )] = z
-
(), RWC RWCx

(3)

. FiequenU _hifting
|

x()] =
z

=; RWC RWC x ed Y ||

(4)




. F0LBINu

|x(-)] = _
1
z
] =; RWC |ueted RWC x

(5)


. 0NPLEX 0N}0uATI0N
|x
-
()] =
-
(z
-
); RWC RWCx

(6)

. BIFFEENTIATI0N IN TE Z- B0NAIN

|()] = -
d()
d


(7)




. N0LTIPLIATI0N
|x1()x2()] =
1
2a
_ 1(u)2(
z
u
/ )u
-1
du; RWC RWCx1 r |teted RWCx2


(8)







8. 0Nv0L0TI0N

age | 33



|x1() - x2()] = 1(z)2(z); RWC RWCx1 rRWCx2 (9)





LAB TA

TASK1. Let () =

u(), < || , find x(z) by definition also find out ROC.


Solution:
X(z) = a
n
z
-n
= (
a
z
)
n
=

- az
-1

0
if
a
z
<

0

=
z
z-a
, |z| > o : |a| < <
=X(z)
B(z)
A(z)
=
z
z-a

B(z) is called the zeros of x(z)and A(z)is called the poles of X(z).


TASK2. Let 1() = 2 +3
-1
+4
-2
and 2() = 3 + 4
-1
+ 5
-2
+
-3
. Determine
3() = 1()2().

MATLAB SCRIPT:

x1 =2,3,4,;
x2 =3,4,5,6,;
x3 =conv(x1,x2)

X3 = 6 17 34 43 38 24


Hence

(z) = +z
-1
+z
-2
+z
-3
+8z
-4
+ z
-5


age | 36

TAK3. 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 =



TASK4.a In MATLAB fucntion residuez is available to compute the residue part
and direct (or polynomial) terms of a rational function in
-1
.
X(Z) =
z
z
2
-z +

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


b=0,1,;
a=3,-4,1,;
R,p,C,=residuezb,a,;

R =


P =



[,
X(Z) =
.
-z
-1
-
.
-.z
-1

TASK4.b Similarly to convert back to the rational function form
b,a,=residuezR,p,C,;
b =


a =




So that

age | 3

(z) =
+

z
-1
-

z
-1
+

z
-2
=
z
-1
-z
-1
+ z
-2
=
z
z
2
-z +

Now applying the same procedure determine inverse z-transform of
(z) =

( -.9z
-1
)
2
( +.9z
-1
)

Hint: use a=poly(0.9,0.9,-0.9) to determine polynimials of a. then apply residuez
method.
TASK5. Pole-zero plot
X(Z) =
z
z
2
-z +

Je can flnd Lhe rooLs of Lhe denomlnaLor polynomlal uslng
%a)Je can also ploL Lhe zeros and poles elLher wlLh
zeros and poles ln n vecLors
den = 3 -4 1,;
roots(den);
p=ans;
z=0,;
zplane(z,p)
Plot the output:





%b)numeraLor and denomlnaLor coefflclenLs ln vecLors
num=0 1 0,;
den=3 -4 1,;
zplane(num,den)
Plot the output:


age | 38

LAB AIuNNENT



P. F[i the given _ignal pl[t the p[le-zei[ pl[t given bel[c anu ciite it_ U[ue.
(z) =

( -.9z
-1
)
2
( +.9z
-1
)



































age | 39

EL-312 SIGNALS AND SYSTEMS
Z-transform LAB 9
PRE-LAB


SYSTEM REPRESENTATION IN THE Z-DOMAIN

e can define the z-domain function (z) ,called the system function. How ever unlike (e
jw
)
, (z) exits for systems that may not be BIBO stable.
(z) = h()z
-

-

(1)

(z)
_ z
-
=
1 +_ z
- N
=1
=
()
()


(2)




SOLUTION TO THE DIFFERENCE EQUATIONS

using z-transform , we now provide a method for obtaining zero input and zero state
responces.we will also discuss the steady -state a and transient responces.our time frame
for these solutions will be nl0.for this purpose we define one-sided z-transform.

+
|x()|
+
(z) = x()

z
-


(3)




1 +Y(- ) = x( -)

=
N
=1
,

(4)





age | 60

LAB TA

TASK1. Given a causal system such that

Y() = . 5Y( -1) + 4Y( - 2) +x()
Find H(z) and sketch its pole-zero plot.

Hint : Use zplane , for pole-zero plot , and observe the output.


TASK2. Given a causal system

(n) = .9(n -) + (n)
anu __te funUti[n i_ a_ (z) =

( - .9z
-1
)
, |Z| > .9
.
Use freqz for magitude and phase response for this sysem and observe the output.


Hint: see MATLAB help for zplane.

>>see "Doc freqz




0L0TI0N:

b = 1,0,;
a = 1,-0.9,;
zplane(b,a)% pole-zero plot
-------------------------------
%magnitude and phase response plot
H,w, = freqz(b,a,100);
magH = abs(H);
phaH = angle(H);
subplot(2,1,1);
plot(w/pi,magH);
grid;
xlabel(`frequency in pi units');

age | 61

ylabel(`Magnitude');
title(`Magnitude Responce')
subplot(2,1,2);
plot(w/pi,phaH); grid
xlabel(`frequency in pi units');
ylabel(`phase in pi units');
title(`Phase responce')

[H,]=freqz(b,a,N), returns N-point frequency
Vector , w,and complex H vector.









Figure1:



age | 62


LAB AIuNNENT

P. A Uau_al LTI __te i_ _table if anu [nl if the __te funUti[n H() ha_ all it_
p[le_ in_iue the unit UiiUle. [ a Uau_al LTI __te i_ ue_Uiibeu be the uiffeienUe equati[n
a_

(n) = .8(n - ) + (n) -(n - )
Determine
a. The system function H(z)
b. Use zplane , for pole-zero plot , and observe the output.

P. [lve the uiffeienUe equati[n

() =
1
3
|() +( -1) +( - 2)] +. 95( -1) -. 925( - 2)
a. The system function H(z)
b. Use freqz for magitude and phase response for this sysem and observe the
output.



















age | 63

EL-312 SIGNALS AND SYSTEMS
LAB 10
PRE-LAB

INTRODUCTION
Laplace transIorm is an important and powerIul tool in system analysis and design. This
transIorm is widely used Ior describing continuous circuits and systems, including automatic
control systems and also Ior analyzing signal Ilow through causal linear time invariant systems
with non-zero initial conditions.
The Laplace transIorm gives the total solution to the diIIerential equation and corresponding
initial and Iinal value problems.

Laplace Transform

Laplace transIorm oI a Iunction I(t) is deIined as



Transfer function
The transIer Iunction is the ratio oI the output Laplace TransIorm to the input Laplace TransIorm
assuming zero initial conditions. Many important characteristics oI dynamic or control systems
can be determined Irom the transIer Iunction.
The general procedure to Iind the transIer Iunction oI a linear diIIerential equation Irom input to
output is to take the Laplace TransIorms oI both sides assuming zero conditions, and to solve Ior
the ratio oI the output Laplace over the input Laplace.
ode Plot
A bode ploL ls a graph of Lhe logarlLhm of Lhe Lransfer funcLlon of a llnear LlmelnvarlanL sysLem versus
frequency ploLLed wlLh a logfrequency axls Lo show Lhe sysLems frequency response lL ls usually a
comblnaLlon of a bode magnlLude ploL %usually expressed as d8 of galn) and a bode phase ploL %usually
expressed as degrees of phase shlfL)

age | 64

LAB TASK

f Lfp|fne 1rfnsform
Laplace transform of a function f(t) can be obtained with Matlab's function laplace.
Syntax
laplace(F)
laplace(F, t)
laplace(F, w, z)
Description
L = laplace(F) is the Laplace transIorm oI the scalar symbol F with deIault independent
variable t. The deIault return is a Iunction oI s. The Laplace transIorm is applied to a Iunction oI
t and returns a Iunction oI s.
L = laplace(F,t) makes L a Iunction oI t instead oI the deIault s.
L = laplace(F,w,z) makes L a Iunction oI z and F a Iunction oI w instead oI the deIault
variables s and t, respectively.
Example 1.
llnd Lhe Laplace Lransform of 1(t) = t
4

You need to first define the variable t as a "symbol".
syms t
Next, enter the function f(t):
f=5*exp(-2*t);
Finally, enter the following command:
L=laplace(f)
Matlab yields the following answer:L=/(S+2)

Example 2.
Find the Laplace transform of f(t)=
-5t

You need to first define the variable t as a "symbol".
syms t
Next, enter the function f(t):
f=t^4;
Finally, enter the following command:
laplace(f)
Matlab yields the following answer:

ans =24/s^5
You may want to carry out the transformation by hand (or using Laplace transform table) to verify
these results.


age | 63

Def|n|ng trfnsfer funnt|on |n Mft|f
n order to enter a transIer Iunction into MATLAB, the variables much be given numerical value,
because MATLAB cannot manipulate symbolic variables without the symbolic toolbox. Enter
the numerator and denominator polynomial coeIIicients separately as vectors oI coeIIicients oI
the individual polynomials in descending order. The syntax Ior deIining a transIer Iunction in
MATLAB is:
transferfunction = tf(num, den)
where num is deIined as the vector oI numerator coeIIicients, and den is deIined as the vector oI
denominator coeIIicients.
MPL
Input the transfer function (s)/(s) 1/|ms
2
bs k| into MATLAB.
For illustration purposes, this example uses m 2, b 5, and k 3.
~~ m 2;
~~ b 5;
~~ k 3;
~~ num | 1 |;
~~ den | m b k |;
~~ tutorialtI tI(num, den)
MATLAB will assign the transIer Iunction under the name tutorialtI, and output the Iollowing:
Transfer function:
1
---------------
2 s^2 + 5 s + 3
Step response using the transfer function
nce the transIer Iunction is entered into MATLAB it is easy to calculate the response to a step
input. To calculate the response to a unit step input, use:
step(transferfunction)
where transIerIunction is the name oI the transIer Iunction oI the system.
ample
ind the unit step response of tutorialtI using MATLAB.
To Iind the unit step response:
step(tutorial_tf)
The MATLAB output will be the following plot of the unit step response:

age | 66




2puIse response using the transfer function
MATLAB can also plot the impulse response oI a transIer Iunction. Because the transIer
Iunction is in the Iorm oI output over input, the transIer Iunction must be multiplied by the
magnitude oI the impulse. The syntax Ior plotting the impulse response is:
impulse(transferfunction)
where u is the magnitude oI the impulse and transferfunction is the name oI the transIer
Iunction oI the system.
MPL
Find the impulse response of tutorial_tf using MATLAB:
impulse(tutorial_tf)
The MATLAB output will be the following plot of the impulse response:
ode PIot using the transfer function
MATLAB`s bode command plots the Irequency response oI a system as a bode plot.
bode(transferfunction)
where transferfunction is the name oI the transIer Iunction system.
MPL
ind bode plot of the frequency response of the system tutorial_tf
using MATLAB.

bode(tutorial_tf)

age | 6

The MATLAB output will be the Iollowing bode plot oI the Irequency response:







age | 68

LAB ASSIGNMENT

These assignment tasks is aimed at having hands on experience with some oI the Matlab
commands and the tools.
1
Use "laplace" to find the Laplace transforms
a) g(t) 5t
-5t
u(t)
b) g(t) |tsin(2t)
-2t
]()
c) g(t) sin(2t)cos(2t)u(t)
2
Take step response of the following transfer functions.
a) G(s)
1
s(s+2)(s+3)

b) G(s)
10
(s+1)
2
(s+3)

c) G(s)
10
(s
2
+s+2)(s+3)


3
Take impulse response of the above transfer function given in part
2.
4
Find bode plots of the above transfer functions in part 2.









age | 69

EL-312 SIGNALS AND SYSTEMS
LAB11
PRE-LAB

INTRODUCTION
Laplace transIorm is an important and powerIul tool in system analysis and design. This
transIorm is widely used Ior describing continuous circuits and systems, including automatic
control systems and also Ior analyzing signal Ilow through causal linear time invariant systems
with non-zero initial conditions.
The laplace transIorm gives the total solution to the diIIerential equation and corresponding
initial and Iinal value problems.

Laplace transIorm oI a Iunction I(t) is deIined as


Inverse ourier Transform
The inverse laplace transIorm is deIined as

C
C

st
ds e s X

t x
9
9
6
) (
2
1
) (
Inverse ourier Transform using partial fraction
n algebra, the partial Iraction decomposition or partial Iraction expansion is used to reduce
the degree oI either the numerator or the denominator oI a rational Iunction. The outcome oI a
Iull partial Iraction expansion expresses that Iunction as a sum oI Iractions, where:
O the denominator oI each term is a power oI a non Iactorable polynomial and
O the numerator is a polynomial oI smaller degree than that irreducible polynomial.
The main motivation to decompose a rational Iunction into a sum oI simpler Iractions is that it
makes simpler to perIorm linear operations on it. ThereIore the problem oI computing
derivatives, anti derivatives, integrals, power series expansions, Fourier series, residues, linear
Iunctional transIormations, oI rational Iunctions can be reduced, via partial Iraction
decomposition, to making the computation on each single element used in the decomposition.

age | 0


LAB TASK

a. Inverse Laplace Transform

The command one uses now is ilaplace.
Syntax
F = ilaplace(L)
F = ilaplace(L,y)
F = ilaplace(L,y,x)
Description
F = ilaplace(L) is the inverse Laplace transIorm oI the scalar symbolic object L with
deIault independent variable s. The deIault return is a Iunction oI t. The inverse Laplace
transIorm is applied to a Iunction oI s and returns a Iunction oI t.
F = ilaplace(L,y) makes F a Iunction oI y instead oI the deIault t.
F = ilaplace(L,y,x) takes F to be a Iunction oI x and L a Iunction oI y instead oI the
deIault variables t and s, respectively.
ne also needs to deIine the symbols t and s.


ample
Lets calculate the inverse oI the Iunction F(s)
s-5
s(s+2)2


syms t s
F=(s-5)/(s(s+2)^2);
ilaplace(F)
ans =
-5/4+(7/2t+5/4)exp(-2t)
simplify(ans)
ans =
-5/4+7/2texp(-2t)+5/4exp(-2t)
pretty(ans)
- 5/4 + 7/2 t exp(-2 t) + 5/4 exp(-2 t)
hich corresponds to I(t) -1.25 3.5te
-2t
1.25e
-2t

Alternatively one can write
ilaplace((s-5)/(s(s+2)^2))


age | 1

Matlab for Laplace Transform Inversion / Partial Fraction Expansion

First Example - Simplest case - distinct real roots
This case will consider only distinct real roots.

DeIine numerator and denominator polynomial.
n=1 1,; %n=s+1
d=conv(1 0,,1 2,); %Use "conv" to multiply polynomial
disp('Numerator = ' poly2str(n,'s'),);
disp('Denominator = ' poly2str(d,'s'),);

umerator = s + 1
Denominator = s^2 + 2 s
ow use "residue" command to do inverse transIorm. r magnitude oI expansion term p
location oI pole oI each term k constnat term (k0 except when numerator and denominator
are same order (mn)).
r,p,k,=residue(n,d)
r =

0.5000
0.5000


p =

-2
0


k =

[]


ote that the Iunction is implicitly deIined only Ior t~0. Some texts show the time domain
Iunction multiplied by the unit step. e will keep our expressions simpler by making that
relationship implicit.


age | 2

Second Example - Repeated roots at origin

DeIine numerator and denominator polynomial.
n=1 0 1,; %n=s^2+1
d=conv(1 0 0,,1 2,); %Use "conv" to multiply polynomial
disp('Numerator = ' poly2str(n,'s'),);
disp('Denominator = ' poly2str(d,'s'),);
r,p,k,=residue(n,d)

umerator = s^2 + 1
Denominator = s^3 + 2 s^2

r =

1.2500
-0.2500
0.5000


p =

-2
0
0


k =

[]

ote, second order pole (s`2) comes second in list.


Third Example - Complex Conjugate roots
e also did this example in class.

DeIine numerator and denominator polynomial.
n=1 0 1,; %n=s^2+1
d=conv(1 0 0,,1 2 5,); %Use "conv" to multiply polynomial
disp('Numerator = ' poly2str(n,'s'),);
disp('Denominator = ' poly2str(d,'s'),);

age | 3


umerator = s^2 + 1
Denominator = s^4 + 2 s^3 + 5 s^2
r,p,k,=residue(n,d)


r =

0.0400 - 0.2200i
0.0400 + 0.2200i
-0.0800
0.2000


p =

-1.0000 + 2.0000i
-1.0000 - 2.0000i
0
0


k =

[]

ote, Iirst two roots are complex conjugate roots.
Get magnitude and phase.
M=2abs(r(1)) %Magnitude of cosine
phi=angle(r(1)) %Phase of cosine
=

0.4472


phi =

-1.3909

Get Irequency and decay rate Irom location oI pole
omega=imag(p(1))
alpha=-real(p(1))
omega =

2


alpha =

1

age | 4



Plot the response
t=0:0.1:4;
f=Mexp(-alphat).cos(omegat+phi) + r(3) + r(4)t;
plot(t,f);
xlabel('Time');
ylabel('f(t)');


Fourth Example - Order of numerator=order of denominator
e also did this example in class.

DeIine numerator and denominator polynomial.
n=3 2 3,; %n=3s^2+2s + 3
d=1 3 2,; %d=s^2+3s+2=(s+1)(s+2)
disp('Numerator = ' poly2str(n,'s'),);
disp('Denominator = ' poly2str(d,'s'),);


age | 3

umerator = 3 s^2 + 2 s + 3
Denominator = s^2 + 3 s + 2

r,p,k,=residue(n,d)


r =

-11
4


p =

-2
-1


k =

3

ote this time that k is not empty, k3.






age | 6

LAB ASSIGNMENT

These assignment tasks is aimed at having hands on experience with some oI the Matlab
commands and the tools.
1
Use "ilaplace" to find the Inverse Laplace transforms
a) G(s)
1
s(s+2)(s+3)

b) G(s)
10
(s+1)
2
(s+3)

c) G(s)
10
(s
2
+s+2)(s+3)

2
Use partial fraction method to find the Inverse Laplace transforms
a) G(s)
1
s(s+2)(s+3)

b) G(s)
10
(s+1)
2
(s+3)

c) G(s)
10
(s
2
+s+2)(s+3)

Vous aimerez peut-être aussi