0% found this document useful (0 votes)
251 views4 pages

Numerical Inversion of Laplace Transforms in Matlab

This document describes a MATLAB function called INVLAP that performs numerical inversion of Laplace transforms. INVLAP provides a simple and accurate way to invert Laplace transforms without needing to compute poles or zeros. It works for functions containing rational, irrational, or transcendental expressions. Examples are provided demonstrating INVLAP inverting various Laplace transforms, including fractional ones.

Uploaded by

Erza Scarlet
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
251 views4 pages

Numerical Inversion of Laplace Transforms in Matlab

This document describes a MATLAB function called INVLAP that performs numerical inversion of Laplace transforms. INVLAP provides a simple and accurate way to invert Laplace transforms without needing to compute poles or zeros. It works for functions containing rational, irrational, or transcendental expressions. Examples are provided demonstrating INVLAP inverting various Laplace transforms, including fractional ones.

Uploaded by

Erza Scarlet
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

Numerical Inversion of Laplace Transforms in Matlab

Inversion of Laplace transforms is a very important procedure used in solution of


complex linear systems.
The function f(t)=INVLAP(F(s)) offers a simple, effective and reasonably accurate way
to achieve the result. It is based on the paper:
J. Valsa and L. Brancik: Approximate Formulae for Numerical Inversion of Laplace
Transforms, Int. Journal of Numerical Modelling: Electronic Networks, Devices and
Fields, Vol. 11, (1998), pp. 153-166
The transform F(s) may be any reasonable function of complex variable s^α, where α is
an integer or non-integer real exponent. Thus, the function INVLAP can solve even
fractional problems and invert functions F(s) containing rational, irrational or
transcendental expressions.
The function does not require to compute poles nor zeroes of F(s). It is based on values of
F(s) for selected complex values of the independent variable s. The resultant
computational error can be held arbitrarily low at the cost of CPU time. With the today’s
computers and their speed this does not present any serious limitation (see Examples).

% INVLAP – Numerical Inversion of Laplace Transforms


function [radt,ft]=INVLAP(Fs,tini,tend,nnt,a,ns,nd);
% Fs is formula for F(s) as a string
% tini, tend are limits of the solution interval
% nnt is total number of time instants
% a, ns, nd are parameters of the method
% if not given, the method uses implicit values a=6, ns=20, nd=19
% it is recommended to preserve a=6
% increasing ns and nd leads to lower error
% an example of function calling
% [t,ft]=INVLAP('s/(s^2+4*pi^2)',0,10,1001);
% to plot the graph of results write plot(t,ft), grid on, zoom on
FF=strrep(strrep(strrep(Fs,'*','.*'),'/','./'),'^','.^');
if nargin==4
a=6; ns=20; nd=19; end; % implicit parameters
radt=linspace(tini,tend,nnt); % time vector
if tini==0 radt=radt(2:1:nnt); end; % t=0 is not allowed
tic % measure the CPU time
for n=1:ns+1+nd % prepare necessary coefficients
alfa(n)=a+(n-1)*pi*j;
beta(n)=-exp(a)*(-1)^n;
end;
n=1:nd;
bdif=fliplr(cumsum(gamma(nd+1)./gamma(nd+2-n)./gamma(n)))./2^nd;
beta(ns+2:ns+1+nd)=beta(ns+2:ns+1+nd).*bdif;
beta(1)=beta(1)/2;
for kt=1:nnt % cycle for time t
tt=radt(kt);
s=alfa/tt; % complex frequency s
bt=beta/tt;
btF=bt.*eval(FF); % functional value F(s)
ft(kt)=sum(real(btF)); % original f(tt)
end;
toc
Examples of inversion of some typical transforms

% example_1 - inversion of an irrational fraction F(s)


clear, close all
[t1,ft1]=INVLAP('tanh(s)/s',0.01,20,1000);
[t2,ft2]=INVLAP('tanh(s)/s',0.01,20,2000,6,280,59);
figure(3)
set(3,'color','white')
subplot(2,1,1)
plot(t1,ft1), grid on, zoom on
xlabel('t [s]'), ylabel('f(t)')
title('rectangular periodic wave')
subplot(2,1,2)
plot(t2,ft2), grid on, zoom on
xlabel('t [s]'), ylabel('f(t)')
title('improved accuracy')

rectangular periodic wave


2

1
f(t)

-1

-2
0 2 4 6 8 10 12 14 16 18 20
t [s]
improved accuracy
2

1
f(t)

-1

-2
0 2 4 6 8 10 12 14 16 18 20
t [s]
% example_2 - inversion of a fractional F(s)
clear, close all
[t1,ft1]=INVLAP('1/(sqrt(s)*s)',0.01,5,200,6,40,20);
[t2,ft2]=INVLAP('(20.5+3.7343*s^1.15)/
(21.5+3.7343*s^1.15+0.8*s^2.2+0.5*s^0.9)/s',0.01,5,200);
figure(4)
set(4,'color','white')
subplot(2,1,1)
plot(t1,ft1), grid on, zoom on
xlabel('t [s]'), ylabel('f(t)')
%title('
subplot(2,1,2)
plot(t2,ft2), grid on, zoom
xlabel('t [s]'), ylabel('f(t)')
title('step response of a fractional control system')

1
F (s) 
s* s

2
f(t)

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
t [s]
step response of a fractional control system
1.5

1
f(t)

0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
t [s]
% example_3 - inversion of a fractional F(s) in symbolic form
clear, close all
syms D1 alfa1 R1 s
% parameters of the network with constant phase element
I=0.25; Rs=0.1; R1=100; D1=1; alfa1=-0.7;
% F(s) in symbolic form
F1=I*(Rs+(R1*D1*s^alfa1/(R1+D1*s^alfa1)))*(1-exp(-4000*s))/s;
% F(s) as a string
F1=char(F1);
% parameters of the fractional control system
k=20.5; a1=3.7343; alfa1=1.15; a2=0.8; alfa2=2.2; a3=0.5;
alfa3=0.9;
F2=(k+a1*s^alfa1)/(k+1+a1*s^alfa1+a2*s^alfa2+a3*s^alfa3)/s; % F(s) in
symbolic form
F2=char(F2); % F(s) as a string
[t1,ft1]=INVLAP(F1,0.01,1e4,1000,6,39,89);
[t2,ft2]=INVLAP(F2,0.01,5,200);
figure(5)
set(5,'color','white')
subplot(2,1,1)
plot(t1,ft1), grid on, zoom on
xlabel('t [s]'), ylabel('f(t)')
title('response to the input current impulse')
subplot(2,1,2)
plot(t2,ft2), grid on, zoom
xlabel('t [s]'), ylabel('f(t)')
title('step response of a fractional control system')

response to the input current impulse


30

20
f(t)

10

0
0 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000
t [s]
step response of a fractional control system
1.5

1
f(t)

0.5

0
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
t [s]

You might also like