Laboratory Report No.
Laplace and Inverse Laplace using MATLAB
I. Objectives:
a) This activity aims to introduce some MATLAB commands that are useful when
treating Laplace and Inverse Laplace Transforms.
b) To gain familiarity for MATLAB codes with Laplace Transforms.
II. Discussion. (Research your own.)
III. Procedure.
Direction: Perform the procedures to obtain the Laplace and Inverse
Laplace Transform of the following equations. Show your MATLAB solution
on part IV.
1.) To obtain the Laplace transform of 𝒇(𝒕) = 𝒆𝟐𝒕 + 𝒕 – 𝒕𝟐 using MATLAB, you can
use the laplace() function. To perform the Laplace transform, type the MATLAB
code:
>> syms t s
To type the function 𝒇(𝒕):
>>f= exp(2*t)+t-t^2;
To compute the Laplace Transform of 𝒇(𝒕):
>>Fs= laplace(f, t, s);
Where the laplace(f, t, s) will compute the Laplace transform of the function
f(t), where t refers to the time variable, and s refers to the Laplace Transform
variable.
To show the result:
>>disp(Fs)
To make the result readable:
>>pretty(Fs)
2.) To obtain the Inverse Laplace of 𝑭(𝒔) = 𝟐𝒔 / 𝒔𝟐 + 𝟏 you can use the ilaplace()
function. To perform the Inverse Laplace transform, type the MATLAB code:
>> syms s t
To type the Laplace function 𝑭(𝒔):
>> expr= 2*s/(s^2+1);
PREPARED BY: ENGR. HAZEL MHAY P. DUCUSIN
To compute the Inverse Laplace transform of 𝑭(𝒔):
>> inv_laplace= ilaplace(expr, s, t);
To show the result:
>> disp(inv_laplace)
3.) To compute the Laplace transform of 𝑢(𝑡 − 1) − 𝑢(𝑡 − 2), which represents a
difference of unit step functions delayed by 1s and 2s, you can use MATLAB’S
heaviside() function. Since the Laplace Transform of a shifted unit step function
𝑒 −𝑎𝑠
𝑢(𝑡 − 𝑎) is , we can apply the Laplace transform of the equation individually
𝑠
to each term.
>> syms t s
To type the unit step functions 𝒖(𝒕 − 𝟏) − 𝒖(𝒕 − 𝟐):
>>u1 = heaviside(t - 1);
>>u2 = heaviside(t - 2);
To compute the Laplace transform of 𝒖(𝒕 − 𝟏) − 𝒖(𝒕 − 𝟐):
>>U1_s = laplace(u1, t, s);
>>U2_s = laplace(u2, t, s);
>> result = U1_s - U2_s;
To show the result:
>>disp(result)
4.) Obtain the Laplace Transform of the differential equation 𝑦” + 5𝑦 ′ + 3𝑦 = 0
𝑦′(0) = 8 & 𝑦(0) = 7. To solve the differential equation using Laplace
transforms in MATLAB, you need to perform the ff:
a) Take the Laplace transform of the differential equation.
b) Substitute the initial conditions into the transformed equation.
c) To solve its Laplace Transform Y(s), type the command:
>> syms s t Y
y0 refers to 𝒚(𝟎)
PREPARED BY: ENGR. HAZEL MHAY P. DUCUSIN
>> y0= 7;
yp0 refers to 𝒚’(𝟎)
>> yp0= 8;
The Laplace Transform of 𝒚” + 𝟓𝒚′ + 𝟑𝒚 = 𝟎
>> eq= s^2*Y-s*y0-yp0+5*(s*Y-y0)+3*Y==0 ;
To solve for Y(s)
>>Ys= solve(eq, Y);
>>disp(Ys)
5.) To obtain the Laplace of 𝑒 −2𝑡 + 5𝑡[𝑢(𝑡 − 2) − 𝑢(𝑡)], you can compute the
Laplace transform of the equation separately and then combine the results.
1
Since the Laplace transform of the equation 𝑒 −2𝑡 + 5𝑡[𝑢(𝑡 − 2) − 𝑢(𝑡)] is 𝑠+2 +
5𝑒 −2𝑠 10𝑒 −2𝑠 5
+ − 𝑠2 (As discussed in the previous lesson on Laplace Transforms).
𝑠2 𝑠
Type the MATLAB code:
>> syms t s
To type the unit step functions [𝒖(𝒕 − 𝟐) − 𝒖(𝒕)]
>>u1 = heaviside(t - 2);
>>u2 = heaviside(t);
To type the function 𝒆−𝟐𝒕 + 𝟓𝒕[𝒖(𝒕 − 𝟐) − 𝒖(𝒕)]
>>f1 = exp(-2*t);
>>f2 = 5 * t * (u1 - u2);
To compute the Laplace tranform of each term:
>>F1s = laplace(f1, t, s);
>>F2s = laplace(f2, t, s);
To combine the results:
>>Fs = F1s + F2s;
To show the result:
>>disp(Fs)
PREPARED BY: ENGR. HAZEL MHAY P. DUCUSIN
To make the result more readable you can use:
>>pretty(Fs)
Activity 1: Find the Laplace Transform of the following continuous-time
functions using manual and MATLAB solution:
1.) 𝑡 2 𝑠𝑖𝑛2𝑡
2.) 𝑐𝑜𝑠ℎ(3𝑡) + 𝑒 −𝑡 𝑠𝑖𝑛(5𝑡)
3.) 𝑦" − 3𝑦′ + 2𝑦 = 0 , 𝑦(0) = 2 & 𝑦′(0) = 3
4.) 5𝑒 −3𝑡 + 2𝑡𝑢(𝑡 − 1) − 𝑢(𝑡 − 2)
5.) 3𝑡 3 (𝑡 − 1) + 𝑒 −5𝑡
Activity 2: Find the Inverse Laplace of the following equations using manual
and MATLAB solution:
𝑠+2
1.) 𝑠2 (𝑠+1)(𝑠+3)
5 9
2.) + 𝑠2 +9
𝑠4
2𝑠+1 3
3.) + 𝑠−1
𝑠2 +9
1
4.) 𝑠(𝑠+1)3 (𝑠+2)
2𝑠+1
5.) (𝑠2 +1)(𝑠−1)(𝑠−3)
IV. Solution.
V. Conclusion.
PREPARED BY: ENGR. HAZEL MHAY P. DUCUSIN