Inverse Laplace Transforms With MATLAB
Inverse Laplace Transforms With MATLAB
Purpose:
The Laplace Transform converts the integral
-
differential equations of electromechanical system into
algebra
-
based equations that can be easily manipulated. However, evaluating the inverse
Laplace
transfor
m can be cumbersome. This lab will introduce some tools in MATLAB that can be
used to find
the inverse Laplace transform.
Procedure:
Fig. 1: RC Circuit with a Switch
The switch closes at
t
= 0. The output is the capacitor voltage.
Select your own valu
es of
R
and
C
. Treat all components as “resistors” and solve for
V
B
in the Laplace
domain.
The voltage divider gives
s
RC
s
V
s
V
sRC
s
V
sC
R
sC
s
V
in
in
in
out
2
1
1
)
(
1
1
)
(
.
The time
-
domain solution requires us to find the inverse Laplace transform.
Method 1
: Using the MAT
LAB built
-
in function residue
Let the denominator be
]
0
1
[
RC
a
and the numerator be
in
V
b
Then the MATLAB function [r, p, K] = residue(b, a) finds the partial fraction
expansion:
K
p
s
r
p
s
r
s
a
s
b
)
2
(
)
2
(
)
1
(
)
1
(
)
(
)
(
Once the partial fraction expansion is obtained, you can write down the inverse
Laplace transform:
)
(
)
2
(
)
1
(
)
(
)
2
(
)
1
(
t
K
e
r
e
r
t
v
t
p
t
p
B
Now plot
v
B
(t)
to ensure that it depicts a charging capacitor. See the Appendix.
Note:
Here we as
sume that we have only simple poles. When the order of the numerator b is lower
than the order of the denominator a, we always have K = 0.
Method 2
: Using the MATLAB’s symbolic calculation and function ilaplace
As an exercise, run the following MATLAB scri
pt to learn about MATLAB’s laplace and ilaplace :
syms t %time variable t
f=2*exp(
-
t)
-
2*t*exp(
-
2*t)
-
2*exp(
-
2*t); %define f(t)
pretty(f) %looks better
F=laplace(f) %Laplace transform
pretty(F) %looks better
F=simplify(F) %combin
e partial fractions
fnew=ilaplace(F) %inverse Laplace transform
pretty(f) %looks better
Now you are ready to do the lab using the second method.
i. Defining the symbolic variables to be used (i.e.
s
)
>> syms s
ii. Writing the Laplace domain func
tion
>> F = b/(R*C*s^2 + s)
iii. Operating on the function
>> f = ilaplace(F)
Now plot
v
B
(t)
to ensure that it depicts a charging capacitor. See the Appendix.
Conclusions:
(1)
Did these two methods give you the same mathematical expression for the inve
rse Laplace
transform?
(2)
Type
(or write)
these two time
-
domain expressions here.
(3)
Run a
Multisim
simulation to verify the time
-
domain
v
B
(
t
) is reasonably correct.
Appendix
: Suggested MATLAB code (Please change your values of
R
and
C
)
clc;
%reset the
workspace command line
clear
all
;
%clear all the variables
close
all
;
%close all the plots
%%====Please use your own value for R and C===================
R = 10000;
%10kohm
C = 0.1*10^(
-
6);
%0.1 uF
%%=======================================================
=====
vin = 5;
%input amplitude=5 V
a = [R*C 1 0];
%denominator
b = vin;
%numerator
%%=========For Plotting==================
set(gca,
'fontsize'
,18,
'FontWeight'
,
'bold'
,
'FontName'
,
'Times New Roman'
);
%%=======================================
% Method 1: Re
sidue
display(
'Method1: Residue'
);
[r, p, K] = residue (b, a)
t=0:0.0001:0.01;
VB=r(1)*exp(p(1)*t)+r(2)*exp(p(2)*t);
subplot(1,2,1)
plot(t, VB)
xlabel(
'Time[s]'
);
ylabel(
'Voltage [V]'
);
title(
'Method 1: Residue'
)
%%%===================================
%
Method 2: Symbolic
display(
'Method2: Symbolic'
);
syms
s
F = b/(a(1)*s^2+a(2)*s)
f = ilaplace(F)
subplot(1,2,2)
ezplot(f, [0, 0.01]);
%ezplot plots function f over the specified range
xlabel(
'Time[s]'
);
ylabel(
'Voltage [V]'
);
title(
'Method 2: Symbolic'
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@