Plotting inverse Laplace transform

2 views (last 30 days)
I want to find the inverse Laplace transform and then plot the graph. Below 👇 is the code: syms s t %defines s and t as symbolic variables.
a=0.05;
b=0.0045;
c=0.067;
f=0.0508;
g=0.2;
h=0.45;
x=2.71828;
j=232679478;
r=0.742;
k=(h+r);
F =(1-g)*b*a*j*x^(c+f))/s*(s+a*x^c)(s+b*x^f) + (r*a*j*g*b*x^(c+f))/s*(s+k)*(s+a*x^c)(s+b*x^f); %Definition of the Function F(s)
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
f = ilaplace(F); %calculates the inverse Laplace transform of F(s), resulting in f(t).
f_func = matlabFunction(f) %converts the symbolic function f(t) into a regular MATLAB function.
% Define the time vector for plotting
t_vec = 0:0.1:10; % time from 0 to 10
% Plot the inverse Laplace transform
plot(t_vec, f_func(t_vec))
xlabel('Time (t)')
ylabel('f(t)')
title('Inverse Laplace Transform Plot')
grid on
I got this Error message: undefined function code for input argument of type 'cher'a=0.05;b=0.0045;c=0.067;f=0.0508;g=0.2;h=0.45;x=2.71828;j=232679478;r=0.742;k=(h+r);F =(1-g)*b*a*j*x^(c+f))/s*(s+a*x^c)(s+b*x^f) + (r*a*j*g*b*x^(c+f))/s*(s+k)*(s+a*x^c)(s+b*x^f); %Definition of the Function F(s)f = ilaplace(F); %calculates the inverse Laplace transform of F(s), resulting in f(t).f_func = matlabFunction(f) %converts the symbolic function f(t) into a regular MATLAB function.% Define the time vector for plottingt_vec = 0:0.1:10; % time from 0 to 10% Plot the inverse Laplace transformplot(t_vec, f_func(t_vec))xlabel('Time (t)')ylabel('f(t)')title('Inverse Laplace Transform Plot')grid onI got this Error message: undefined function code for input argument of type 'cher'
  7 Comments
Sunday Aloke
Sunday Aloke on 21 Mar 2025

@Sam Chak The image is not downloading. No response whenever I click on it

Sam Chak
Sam Chak on 21 Mar 2025
Perhaps you can find a free image hosting website that requires no registration and allows for simple drag-and-drop functionality, such as Imagebam, Imgbb, or Imgur. Then copy and paste the link in your comment.

Sign in to comment.

Accepted Answer

David Goodmanson
David Goodmanson on 22 Mar 2025
Edited: David Goodmanson on 22 Mar 2025
Hi SA
Speculative answer: I don't believe that the function F is a likely candidate for a Laplace transform. What you have is (looking at just the first term)
F = const/s*(s+a*x^c)*(s+b*x^f)
which is actually (by mistake?)
(const/s)*(s+a*x^c)*(s+b*x^f)
i.e. two factors involving s in the numerator. For the inverse transforn, that leads to stuff like the derivative of a delta function. What seems more likely is
const/(s*(s+a*x^c)*(s+b*x^f))
with all the s factors in the denominator. Similarly for the second term.
Both terms have a factor of s in the denominator. If
invLaplace(g(s)/s) = G(t)
then removing the s in the denominator effectively multplies by s and gives the time domain derivative,
invLaplace(g(s)) = dG(t)/dt.
The code below does both cases.
syms s t
a=0.05;
b=0.0045;
c=0.067;
f=0.0508;
g=0.2;
h=0.45;
x=2.71828;
j=232679478;
r=0.742;
k=(h+r);
d1 = (1-g)*b*a*j*x^(c+f)
d2 = r*a*j*g*b*x^(c+f)
F = d1/(s*(s+a*x^c)*(s+b*x^f)) + d2/(s*(s+k)*(s+a*x^c)*(s+b*x^f));
Fs = d1/( (s+a*x^c)*(s+b*x^f)) + d2/( (s+k)*(s+a*x^c)*(s+b*x^f));
f = ilaplace(F);
fs = ilaplace(Fs);
f_fun = matlabFunction(f);
fs_fun = matlabFunction(fs);
% Define the time vector for plotting
tvec = 0:2000; % extend the time
y = f_fun(tvec);
ys = fs_fun(tvec);
% Plot the inverse Laplace transform
figure(1)
plot(tvec,ys)
grid on
xlabel('Time (t)')
ylabel('df(t)/dt')
title('Inverse Laplace Transform Plot')
grid on
figure(2)
plot(tvec,y)
grid on
xlabel('Time (t)')
ylabel('f(t)')
title('Inverse Laplace Transform Plot')
grid on

More Answers (0)

Tags

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!