f = 
Plotting inverse Laplace transform
Show older comments
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)
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
Sam Chak
on 21 Mar 2025
Hi Sunday,
Could you write out the transfer function F(s) on a piece of paper and take a photo? Later, we can check if it is correctly coded. Of course, you can also verify it yourself.
You have an extra right parenthesis (that I deleted), and two missing operators (that I added as multiplication operators). The ‘f’ expression is a function of the
function and its first and second derivative. The function itself appears to be a constant, since its integral is an ascending straight line.
You most likely need to check to be certain that ‘f’ is correct, then try again.
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)
f = ilaplace(F); %calculates the inverse Laplace transform of F(s), resulting in f(t).
f = vpa(simplify(f, 500), 5)
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
figure
fplot(f, [0 10])
xlabel('Time (t)')
ylabel('f(t)')
title('Inverse Laplace Transform Plot')
grid on
figure
fplot(int(f), [0 10])
xlabel('Time (t)')
ylabel('\int{f(t)}')
title('Inverse Laplace Transform Plot')
grid on
.
Walter Roberson
on 21 Mar 2025
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)
1 0 1 0v 0 v0 v 0 1 0v 0 v 0 v0 v
The number below each ( ) is the number of open brackets "after" the effect of the symbol above it. Here, "v" has been used to represent -1 -- the case where there has been one too many ")"
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)
^^ ^^
In MATLAB, the only case in which you can have two adjacent () expressions, is the case where the first one is a table variable dot index. For example,
T.(EXPRESSION)(INDEX)
is valid where EXPRESSION is either a string constant or a character vector or a positive integer.
Other than that exception for table dot indexing, adjacent () expressions are forbidden.
There is absolutely no implied multiplication in MATLAB -- not anywhere . (Including for internal MuPAD symbolic expressions.) . All multiplication must be indicated explicitly, using either the .* operator or the * operator.
Sunday Aloke
on 21 Mar 2025
Sam Chak
on 21 Mar 2025
Sunday Aloke
on 21 Mar 2025
Accepted Answer
More Answers (0)
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



