%MATLAB program to compute and plot the Laplace transform of a
given
function
%Example : f_t = exp(-2*t) * sin(3*t);
syms t s; %Define symbolic variables
%Define the function in the time domain
f_t = input('Enter the values of f_t:\n'); %inputting the values
of F_t
%Compute the laplace transform of the function
F_s = laplace(f_t,t,s);
%Plot the original function and its Laplace transform
figure;
subplot(2,1,1);
ezplot(f_t,[0,10]);
title('original function f(t)');
xlabel('Time (t)');
ylabel('f(t)');
subplot(2,1,2);
ezplot(F_s,[0,10]);
title('Laplace transform f(s)');
xlabel('frequency (s)');
ylabel('F(s)');
OUTPUT
Enter the values of f_t:
sin(t)+cos(t)
% Compute the convolution of two functions in the
Laplace domain using MATLAB
clc;
clear;
close all;
syms s t;
% Define the Laplace transforms of the two functions
F1_s = 1/(s^2 + 1); %Laplace of sin(t)
F2_s = 1/(s + 2); %Laplace of e^(-2t)
% Compute product in Laplace domain
Product_s = F1_s * F2_s;
% Inverse Laplace to get convolution in time domain
Convolution_t = ilaplace(Product_s, s, t);
% Display result
disp('Convolution in time domain:');
disp(Convolution_t);
% Plotting the result
fplot(Convolution_t, [0,10], 'LineWidth',2);
grid on;
title('Convolution of sin(t) and e^{-2t}');
xlabel('Time (t)');
ylabel('Convolution(t)');
OUTPUT
%MATLAB provide the ilaplace function to compute the
inverse Laplace transform of a given function
%Example : F_s = 1 / (s^2+4);
syms s t;
%Define the Laplace domain function
F_s = input('Enter the values of F_s:\n'); %inputting
the values of F_s
%Compute the inverse laplace transform of the function
f_t = ilaplace(F_s);
%Plot the inverse laplace transform
t_values = linspace(0,10,100)
f_values = subs(f_t,t,t_values)
plot(t_values, f_values)
title('Inverse Laplace Transform');
xlabel('Time (t)');
ylabel('f(t)');
OUTPUT
Enter the values of F_s: 1/(s^2+4)
t_values =
Columns 1 through 13
0 0.1010 0.2020 0.3030 0.4040 0.5051 0.6061 0.7071 0.8081
0.9091 1.0101 1.1111 1.2121
Columns 14 through 26
1.3131 1.4141 1.5152 1.6162 1.7172 1.8182 1.9192 2.0202 2.1212
2.2222 2.3232 2.4242 2.5253
Columns 27 through 39
2.6263 2.7273 2.8283 2.9293 3.0303 3.1313 3.2323 3.3333 3.4343
3.5354 3.6364 3.7374 3.8384
Columns 40 through 52
3.9394 4.0404 4.1414 4.2424 4.3434 4.4444 4.5455 4.6465 4.7475
4.8485 4.9495 5.0505 5.1515
Columns 53 through 65
5.2525 5.3535 5.4545 5.5556 5.6566 5.7576 5.8586 5.9596 6.0606
6.1616 6.2626 6.3636 6.4646
Columns 66 through 78
6.5657 6.6667 6.7677 6.8687 6.9697 7.0707 7.1717 7.2727 7.3737
7.4747 7.5758 7.6768 7.7778
Columns 79 through 91
7.8788 7.9798 8.0808 8.1818 8.2828 8.3838 8.4848 8.5859 8.6869
8.7879 8.8889 8.9899 9.0909
Columns 92 through 100
9.1919 9.2929 9.3939 9.4949 9.5960 9.6970 9.7980 9.8990 10.0000
f_values =
[0, sin(20/99)/2, sin(40/99)/2, sin(20/33)/2, sin(80/99)/2, sin(100/99)/2, sin(40/33)/2,
sin(140/99)/2, sin(160/99)/2, sin(20/11)/2, sin(200/99)/2, sin(20/9)/2, sin(80/33)/2,
sin(260/99)/2, sin(280/99)/2, sin(100/33)/2, sin(320/99)/2, sin(340/99)/2, sin(40/11)/2,
sin(380/99)/2, sin(400/99)/2, sin(140/33)/2, sin(40/9)/2, sin(460/99)/2, sin(160/33)/2,
sin(500/99)/2, sin(520/99)/2, sin(60/11)/2, sin(560/99)/2, sin(580/99)/2, sin(200/33)/2,
sin(620/99)/2, sin(640/99)/2, sin(20/3)/2, sin(680/99)/2, sin(700/99)/2, sin(80/11)/2,
sin(740/99)/2, sin(760/99)/2, sin(260/33)/2, sin(800/99)/2, sin(820/99)/2, sin(280/33)/2,
sin(860/99)/2, sin(80/9)/2, sin(100/11)/2, sin(920/99)/2, sin(940/99)/2, sin(320/33)/2,
sin(980/99)/2, sin(1000/99)/2, sin(340/33)/2, sin(1040/99)/2, sin(1060/99)/2, sin(120/11)/2,
sin(100/9)/2,sin(1120/99)/2, sin(380/33)/2, sin(1160/99)/2, sin(1180/99)/2, sin(400/33)/2,
sin(1220/99)/2,sin(1240/99)/2,sin(140/11)/2, sin(1280/99)/2, sin(1300/99)/2, sin(40/3)/2,
sin(1340/99)/2, sin(1360/99)/2, sin(460/33)/2,sin(1400/99)/2, sin(1420/99)/2, sin(160/11)/2,
sin(1460/99)/2, sin(1480/99)/2, sin(500/33)/2, sin(1520/99)/2,sin(140/9)/2, sin(520/33)/2,
sin(1580/99)/2, sin(1600/99)/2, sin(180/11)/2, sin(1640/99)/2,sin(1660/99)/2,sin(560/33)/2,
sin(1700/99)/2, sin(1720/99)/2, sin(580/33)/2, sin(160/9)/2, sin(1780/99)/2,
sin(200/11)/2,sin(1820/99)/2, sin(1840/99)/2, sin(620/33)/2, sin(1880/99)/2, sin(1900/99)/2,
sin(640/33)/2, sin(1940/99)/2, sin(1960/99)/2, sin(20)/2]
Inverse Laplace Transform
0.5
0.4
0.3
0.2
0.1
f(t)
-0.1
-0.2
-0.3
-0.4
-0.5
0 1 2 3 4 5 6 7 8 9 10
Time (t)