Inverse Laplace plot error

Guys, I have a problem with this code, I've been trying to fix it for an hour and nothing.
When I plot the inverse laplace graph, the following error appears:
Error using plot
Data must be numeric, datetime, duration or an array convertible to
double.
clear all
close all
clc
syms s t;
D=23;
QT=348000;
Tc=300;
F= (((sqrt(2)*sqrt(D^2*QT^2/s)*8*D^2*QT^2-3*Tc^2*s^2))/(8*D^2*QT^2-Tc^2*s^2));
f=ilaplace (F);
f1=symfun(f,t)
t=[0:0.1:200];
plot(t,f1(t))
Can someone help me?

3 Comments

You need to use the fplot function, however the problem prior to that is that the Laplace domain function cannot be inverted —
syms s t;
D=23;
QT=348000;
Tc=300;
F= (((sqrt(2)*sqrt(D^2*QT^2/s)*8*D^2*QT^2-3*Tc^2*s^2))/(8*D^2*QT^2-Tc^2*s^2))
F = 
f=ilaplace (F);
f1=symfun(f,t);
f1 = subs(f1, dirac(t), 1)
f1(t) = 
% t=[0:0.1:200];
figure
fplot(f1, [0 200])
Warning: Error updating FunctionLine.

The following error was reported evaluating the function in FunctionLine update: Unable to convert expression containing remaining symbolic function calls into double array. Argument must be expression that evaluates to number.
The problem appears to be the term. That is nonlinear in s and that is a problem for inverting Laplace transforms. (The function can be dealt with by setting it equal to 1.)
.
What is the justification for substituting 1 for dirac(t)?
The function won’t plot, however 1 will, since the objective is to plot the function.

Sign in to comment.

Answers (1)

Hi PTK,
f1 is a symfun, so you could use fplot, or you could evaluate it at bunch of points and convert to double and the use plot, as shown below.
However, in this case ilaplace was not able to find a closed-form expression for f1, so neither approach will work. Are you sure the sqrt(1/s) is what's intended.
Also, f1(t) contains a dirac delta function. So even if f1 was in closed form otherwise, be careful using fplot because it ignores dirac delta functions, and evaluationg numerically can be tricky as well.
clear all
close all
clc
syms s t;
D=23;
QT=348000;
Tc=300;
F= (((sqrt(2)*sqrt(D^2*QT^2/s)*8*D^2*QT^2-3*Tc^2*s^2))/(8*D^2*QT^2-Tc^2*s^2))
F = 
f=ilaplace (F);
f1=symfun(f,t)
f1(t) = 
t=[0:0.1:200];
plot(t,double(f1(t)))
Error using symengine
Unable to convert expression containing remaining symbolic function calls into double array. Argument must be expression that evaluates to number.

Error in sym/double (line 872)
Xstr = mupadmex('symobj::double', S.s, 0);

Asked:

PTK
on 26 Jan 2023

Commented:

on 26 Jan 2023

Community Treasure Hunt

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

Start Hunting!