0% found this document useful (0 votes)
4 views27 pages

Document (6)

The document is a laboratory manual for Electrical Network Analysis focusing on Laplace and Inverse Laplace Transforms using MATLAB. It covers concepts of complex frequency, the application of Laplace transforms for time-varying functions, and methods for inverse Laplace transforms, including the use of MATLAB for polynomial manipulations and plotting. The manual provides practical examples and commands to assist students in understanding and applying these concepts in their lab work.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views27 pages

Document (6)

The document is a laboratory manual for Electrical Network Analysis focusing on Laplace and Inverse Laplace Transforms using MATLAB. It covers concepts of complex frequency, the application of Laplace transforms for time-varying functions, and methods for inverse Laplace transforms, including the use of MATLAB for polynomial manipulations and plotting. The manual provides practical examples and commands to assist students in understanding and applying these concepts in their lab work.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 27

Electrical Network Analysis

(EL-2004)

LABORATORYMANUAL
Fall 2023

LAB10
Laplace & Inverse Laplace Transforms on
MATLAB
Arslan Ahmed

AHMEDMASOOD 22I-1814 B 10/29/2023


STUDENTNAME ROLLNO SEC DATE

______________________________________
LABENGINEERSIGNATURE&DATE

MARKS AWARDED: /10


________________________________________________________________
NATIONAL UNIVERSITY OF COMPUTER AND EMERGING SCIENCES (NUCES), ISLAMABAD

Prepared by: Engr. Aamer Munir Version: 1.0


Verified by: Engr. Azhar Rauf Date: 25 October, 2023 Last Edited by: Arslan Ahmed Date: 24 October, 2023
Laplace & Inverse Laplace Transforms on MATLAB LAB: 10
LA
B 1
: 0 Laplace & Inverse Laplace Transforms on MATLAB
Learning Objectives:

• Understanding the concept of complex frequency


• Introduction to MATLAB
• Laplace transform for time varying functions on MATLAB • Residue method for inverse
Laplace transform on MATLAB

Basics of Complex Frequency:

When faced with time-varying sources, or a circuit with switches installed, we have several
choices with respect to the analysis approach. Unfortunately, not all sources are sinusoidal, and there
are times when both transient and steady-state responses are required. In such instances, the complex
frequency allows us to manipulate both periodic and non-periodic time-varying quantities in parallel,
simplifying the analysis. Laplace transform proves to be a highly valuable tool to transform the signals
from time domain to frequency domain.

To give an idea about complex frequency, we consider an exponentially varying sinusoid. V(t)
= Vm eσt cos (ωt + θ)

Here V(m) is the amplitude of sinusoid with angular frequency w and phase shift of θ. σ is a
constant representing exponential delay or rise. Three general cases can be obtained from the above
exponential sinusoid.

Case 1: If we set σ = ω = 0 then a constant DC signal V(t)= Vm cos θ = V0 is obtained.


Case 2: If σ=0, we obtain a general sinusoidal voltage v(t)= Vm cos(ωt + θ).
Case 3: If ω = 0, we have the exponential voltage v(t) = Vm cos θ eσt = V0eσt.
Laplace & Inverse Laplace Transforms on MATLAB LAB: 10
Fig 1 (a): Exponential Sinusoid Fig 1 (b): case 1 constant dc signal

Fig 1 (c): case 2 sinusoid Fig 1 (d): case 3 exponential

Further extending the equation using Euler identity we get.


V(t) = Vm eσt cos (ωt + θ)
V(t)= ½*Vm*eσt [e j(ωt+θ) + e− j(ωt+θ)] v(t) =
½*Vm*e jθ e j(σ+ jω)t + ½*Vm*e− jθ e j(σ− jω)t

The term S = σ + jω in the above equation is known as complex frequency. There are conjugate
complex pair of frequencies as s1 = σ + jω and s2 = σ – jω. The real part of S is σ which is the Neper
frequency that is associated with the exponential variation. If its value is negative, the function
decays as t increases and its value is positive, the function grows with time. The imaginary part of S is
the familiar radian frequency associated with the sinusoidal variation.

Laplace Transform:

It is an integral transform that converts a function of a time (real variable ) to a function of a


complex frequency. The transform has many applications in science and engineering because it is a
tool for solving differential equations. In particular, it transforms integro-differential equations into
algebraic equations and convolution into multiplication. Usually, integration is done from zero to
infinity for single sided transform.

Given below is a brief table containing all the pairs for Laplace and inverse Laplace of various
kind of signals in time and frequency domain.
Laplace & Inverse Laplace Transforms on MATLAB LAB: 10

Fig 2: Laplace transform table of various time varying signals

Inverse Laplace Technique for Rational Functions and Method of Residues:

To convert the signal back into time domain, inverse Laplace is used.

This formula is seldom used since each pair of transform pair and its time-varying function is
unique, so can be easily found from the previously given table.

In analyzing circuits with multiple energy storage elements, we will often encounter s-domain
expressions that are ratios of s-polynomials of the form V(s) = N(s)/D(s)

Where N (s) and D (s) are polynomials in S, the values of s which lead to N(s) = 0 are referred to
as zeros of V(s), and those values of s which lead to D(s) = 0 are referred to as poles of V(s).

It is often possible to decompose these expressions using the method of residues into simpler
terms whose inverse transforms are already known. The criterion for this is that V(s) must be a
rational function for which the degree of the numerator N(s) must be less than that of the
denominator D(s). If it is not, we must first perform a simple division step.
Laplace & Inverse Laplace Transforms on MATLAB LAB: 10
In employing the method of residues, it is first necessary to factor the s-polynomial that comprises
D(s) into a product of binomial terms. The roots of D(s) may be any combination of distinct or
repeated roots and may be real or complex. However, that complex roots always occur as conjugate
pairs provided that the coefficients of D(s) are real.

For distinct real poles, fraction in s is written as V(s)


= 1/(s + α)(s + β)

The denominator has been factored into two distinct roots, −α and −β. Using partial-fraction
expansion, we can split the given transform into the sum of two simpler transforms and can use
linearity theorem to obtain inverse transform very easily.

V(s) = A/(s + α) + B/(s + β) where A and B are residues and alpha and beta are the poles.

For Repeated Poles, consider the function


V(s) = N(s)/(s − p)n which we want to expand into

V(s) = an/(s − p)n +an−1/(s − p)n−1 + ··· +a1/(s − p). Solving through partial fraction expansion gives
values of residues an, an-1, an-2, … a1 and then Laplace transform table can be used to find out
inverse transform easily.
Laplace & Inverse Laplace Transforms on MATLAB LAB: 10
Software Used:

For functions with higher-order polynomials in their denominators, the method of residues is
somewhat complex. In these instances, MATLAB can also be of assistance, as it contains several
useful functions for the manipulation of polynomial expressions. Also, Laplace transform can be
directly obtained using MATLAB.

About MATLAB:

• Double-click on the MATLAB shortcut icon on your Windows desktop. When you start
MATLAB, a special window called the MATLAB desktop appears. The desktop is a window
that contains other windows.

• The major tools within or accessible from the desktop are

• The Command Window is where you type in MATLAB commands. These can be simple
equations you want evaluated, or more complex expressions involving MATLAB scripts or
functions.

• The Command History Window shows the commands you have entered in the past. You can
repeat any of these commands by double-clicking on them, or by dragging them from the
Command History Window into the Command Window.

• The Workspace shows the list of variables that are currently defined, and what type of variable
each is. (i.e., a simple scalar, a vector, or a matrix, and the size of all arrays.) Depending on the
size (i.e., type) of the variable, its value may also be shown.

• The Current Directory Window shows the contents of the current working directory.

• The Help menu also provides a wide variety of useful sources of help.
Laplace & Inverse Laplace Transforms on MATLAB LAB: 10

• The Getting Started link leads to the MATLAB tutorial system. Inexperienced users are
encouraged to go through the tutorials in the order in which they are presented.

Fig 3: Graphical Interface of MATLAB window


Laplace & Inverse Laplace Transforms on MATLAB LAB: 10
Declaring Variables:
You can enter a command at the >> command window.

MATLAB is an interpreted environment. In other words, you give a command and MATLAB
executes it right away. The syntax of variable assignment is:

Variable name = a value (or an expression)

Exampl
e 1: >>x=5
x= 5
Always
declare
variable of
syms type if
you do not
want to
assign the
value.

>> Syms x y z;

Once a variable has been created, it can be reassigned. In addition, if you do not wish to see the
intermediate results, you can suppress the numerical output by putting a semicolon (;) at the end of the
line. Then the sequence of commands looks like this:

>> t =
5; >> t =
t+1 t=6

Let us suppose you want to calculate the expression, 1 + 2×3. You type it in command window as

>>
1+2*3 ans
=7

If you do not specify an output variable, MATLAB uses a default variable ans, short for
answer, to store the results of the current calculation. You may assign a value to a variable or output
argument name.

For example,

>> x =
1+2*3 x =7

MATLAB by default displays only four decimals in the result of the calculations, however
some examples of the different formats together with the resulting outputs are given.
Laplace & Inverse Laplace Transforms on MATLAB LAB: 10
>> format short >> x=-163.6667 format
long>> x= -1.636666666666667e+00

The percent symbol (%) is used for indicating a comment


Example 2:
x = 9 % assign the value 9 to x
You can also write a block of comments using the block comment operator’s % {and %}. The
MATLAB editor includes tools and context menu items to help you add, remove, or change the format
of comments. MATLAB is case-sensitive.

The who command displays all the variable names you have used. While, whos will give more
details which include size, space allocation, and class of the variables.

To clear the Command Window, type clc.

Example 3:
>>who
xyz

The contents of the workspace persist between the executions of separate commands. Therefore, it
is possible for the results of one problem to influence the next one. To avoid this possibility, it is a
good idea to issue a clear command at the start of each new independent calculation.

The command clear or clear all removes all variables from the workspace. This frees up
system memory.

>> clear

It is possible to keep track of everything done during a MATLAB session with the diary command
“>> diary” or give a name to a created file,

>> diary FileName

Where FileName could be any arbitrary name you choose. The function diary is useful if you want
to save a complete MATLAB session. They save all input and output as they appear in the MATLAB
window. When you want to stop the recording, enter diary off. If you want to start recording again,
enter diary on. The file that is created is a plain text file. This command is useful, for example in the
process of preparing homework or lab submission.

Declaring Polynomial:

Declaring a polynomial in MATLAB is quite easy. You must declare the vector and can convert it
into symbolic representation by using the poly2sym () command. Getting back in the form of an array
using sym2poly() command

Example 4:
Laplace & Inverse Laplace Transforms on MATLAB LAB: 10
Write x2 − 3x + 34

>> x = [1 -3 34]
>> answer = poly2sym (x)
answer = x^2-3*x+34
>> answer1 = sym2poly (answer)
answer1 =
1 -3 34
These two representations are not equal in MATLAB; they are two distinct

concepts. In MATLAB we can declare polynomial with different variable t using

poly2sym (x, t)

Example 5:
Write x5 − 3x + 44

>>syms t;
>> x = [1 0 0 0 -3 44] >>
answer = poly2sym (x, t)
answer = t^5-3*t+44

Example 6:

To find the roots of a given polynomial, you must use the command “roots ().”
For example
>> z = roots(x); %x is the matrix
>> ans=
-2.1917 + 0.000i
-0.6100 + 2.0646i
0.61100 – 2.0646i
1.7059 + 1.1922i
1.7059 – 1.1922i

Partial Fraction Expansion:

[r,p,k] = residue (b, a)

command in MATLAB finds the residues, poles, and direct term of a Partial Fraction Expansion of
the ratio of two polynomials, where the expansion is of the form

The inputs to residue are vectors of coefficients of the polynomials b = [bm ... b1 b0] and a =
[an ... a1 a0].
Laplace & Inverse Laplace Transforms on MATLAB LAB: 10

The outputs are the residues r = [rn ... r2 r1], the poles p = [pn ... p2 p1], and the polynomial
k. For most textbook problems, k is zero or a constant.
vector k occurs because of conversion of improper fraction to proper rational fraction. Note that if
the order of the numerator polynomial is less than the order of the denominator polynomial, the vector
k(s) will always be empty.
Example 7:
F (s) =−4s + 8 / s2 + 6s + 8

We write coefficients of numerator and denominator polynomial using row matrix form.

>> b= [-4 8];


>> a= [1 6 8];

The roots of denominator which are poles of rational fraction can also be obtained by invoking the
function
>>roots (a)

Partial fraction can be


obtained as: >> [r, p, k] =residue
(b, a) r = -12 8 p =
-4

-2 k
=
[]

You can write this in the partial fraction expansion form as:

Now we can convert (take inverse Laplace) the partial fraction form to time domain easily as
follows:

We can convert [r, p, k] form back in fraction form by using residue command again

>> [b, a] = residue (r,


p, k) b = -4 8 a = 1 6 8
Laplace & Inverse Laplace Transforms on MATLAB LAB: 10
The MATLAB command to plot a graph is plot(x,y). Axis can be labeled out using x label, y label
command. Title can be mentioned.

>> x = 0:pi/100:2*pi;
>> y =
sin(x); >>
plot(x,y)

Row matrix, Column Matrix, identity matrix, null matrix can be written and generated in
MATLAB using brackets, semi colon and coma. Transpose, inverse, and indexing can be obtained. We
can multiply, add, and subtract them. >>inv([1 2;3 4]

On the other hand, array arithmetic operations other than matrix operation, are done element by
element.
>> C = A.*B

With matrix notation, a system of simultaneous linear equations is written Ax=b. The result is
x=A−1b.

Script file is an external file that contains a sequence of MATLAB statements. Script files have a
filename extension .m and are often called M-files. File→ New→ M-file

MATLAB offers if-else statements, for loop and while loop and switch commands.

There is an extensive list of mathematical functions that are built into MATLAB. Many standard
mathematical functions, such as sin(x), Cos(x), tan(x), exp, log(x), min, max, avg, inv, are evaluated
by MATLAB.

Laplace transform using MATLAB:

Calculating the Laplace F(s) transform of a function f (t) is quite simple in MATLAB.
Define the variables using syms function and write function in time domain and use Laplace
command.
F(t)=-1.25+3.5te-2t+1.25e-2t

>> syms t s
>> f=-1.25+3.5*t*exp(-2*t)+1.25*exp(-2*t);
>> F=laplace(f,t,s)
>> simplify(F)
>> pretty(ans)
It gives ans = (s-5)/s*(s+2)2

To make the expression more readable one can use the commands, simplify and pretty.
Laplace & Inverse Laplace Transforms on MATLAB LAB: 10

Inverse Laplace using MATLAB: ilaplace command can be used

directly or method of residues can be used.

Lab Tasks:
Task 1:
Laplace & Inverse Laplace Transforms on MATLAB LAB: 10

𝑥2 + (𝑦 - 𝑧)
Create a file with your name and implement all these commands.
a.

b. 𝑒-𝑢𝑡

𝑧 = (56 ∗ 7) - (2 ∗ 3)
c. 1⁄𝑥2
d.
Laplace & Inverse Laplace Transforms on MATLAB LAB: 10

Task 2:

Using the above-mentioned commands declare the polynomials and find roots.
a. 512v6 + 99v4

b. 3x3 − 34
c. 7q8 + 3q2 Task 3:
Do the partial fraction expansion of the following expressions:
Laplace & Inverse Laplace Transforms on MATLAB LAB: 10

H (s) =

H (t) =
Laplace & Inverse Laplace Transforms on MATLAB LAB: 10

T (z) =
Laplace & Inverse Laplace Transforms on MATLAB LAB: 10

T (t) =
Laplace & Inverse Laplace Transforms on MATLAB LAB: 10

G (z) =
Laplace & Inverse Laplace Transforms on MATLAB LAB: 10

G (t) =
Laplace & Inverse Laplace Transforms on MATLAB LAB: 10
Laplace & Inverse Laplace Transforms on MATLAB LAB: 10
Task 4:
1. F(t) = 5e−6t

F(s) =

2. 𝐴(𝑡) = 𝑆𝑖𝑛 (𝑎𝑡)


Laplace & Inverse Laplace Transforms on MATLAB LAB: 10

3. 𝑆(𝑡) = 𝑇𝑒−𝑎𝑡
A(s) =

S(s) =
Laplace & Inverse Laplace Transforms on MATLAB LAB: 10

4. 𝑓(𝑡) = −1.25 + 3.5𝑡𝑒−2𝑡 + 1.25𝑒−2t


Laplace & Inverse Laplace Transforms on MATLAB LAB: 10

F(s) = Task 5:
Find the inverse Laplace of the following functions:
Laplace & Inverse Laplace Transforms on MATLAB LAB: 10

F (t) =

F (t) =
Laplace & Inverse Laplace Transforms on MATLAB LAB: 10
Task 6 (Optional):
a. Find Laplace transform of function f(t)=4-4e-2tcos(t)+2e-2tsin(t) using laplace command.

b. Find inverse Laplace transform using ilaplace command and residue method on MATLAB
only for a function in s domain as 3/s3+5s2+8s+4.

You might also like