Trouble with inverse laplace operation

I'm trying to run a code like this:
s = tf('s')
sys = exp(-0.1*s);
sysx = pade(sys,3);
x0 = randn(10,1);
L = D-A (A,D,L are constant matrices)
H = 1/(s+L*sysx);
K = H*x0;
ilaplace(K)
Essentially, I want to get a vector x(t) in the end as per the equation xdot = -Lx(t-0.1).
But this returns the error: Undefined function 'ilaplace' for input arguments of type 'tf'.
How do I go about this? Thanks a lot.

 Accepted Answer

You go about it with difficulty, because the Control System Toolbox and Symbolic Math Toolbox do not have any way of communicating with each other without your intervention.
Try this:
s = tf('s');
sys = exp(-0.1*s)
sysx = pade(sys,3)
sysxn = sysx.Numerator;
sysxd = sysx.Denominator;
x0 = randn(10,1);
syms A D L s t
L = D-A; % (A,D,L are constant matrices)
Nsysx = poly2sym(sysxn{:}, s);
Dsysx = poly2sym(sysxd{:}, s);
TFsysx = Nsysx / Dsysx;
H = 1/(s+L*TFsysx);
K = H*x0;
kh(t) = ilaplace(K, s, t);
kh(t) = vpa(kh(t), 5)
The result are a (10x1) symbolic function vector in ‘t’, ‘z’, and ‘s4’ that I will leave it to you to untangle.
Personally, I would not involve the Symbolic Math Toolbox at all, and instead evaluate the system with step, impulse, or lsim, and be happy with the result.

4 Comments

Hi, thanks for your inputs. (L,D,A are constant integer matrices). When I run the code, it gives the following error while executing H = 1/(s+L*TFsysx);
Error using symengine Operands are invalid.
Error in sym/privBinaryOp (line 937) Csym = mupadmex(op,args{1}.s, args{2}.s, varargin{:});
Error in / (line 323) X = privBinaryOp(A, B, 'symobj::mrdivide');
This code worked for you, I presume? Thanks.
My pleasure.
You did not state what ‘L’, ‘D’ and ‘A’ actually were with respect to size, or modeled them as symbolic matrices. So I modeled them as symbolic scalar constants.
I simply presented an approach you can experiment with.
In all likelihood, it is not possible to do what you want. I would stay with the Control System Toolbox and not involve the Symbolic Math Toolbox at all here.
I understand. I stuck to the Control System Toolbox and used this instead:
s = tf('s')
sys = exp(-0.1*s);
sysx = pade(sys,3);
x0 = randn(10,1);
D = diag([2 3 4 4 4 4 4 4 3 2]);
A = [0 1 1 0 0 0 0 0 0 0;1 0 1 1 0 0 0 0 0 0;1 1 0 1 1 0 0 0 0 0;0 1 1 0 1 1 0 0 0 0;0 0 1 1 0 1 1 0 0 0;0 0 0 1 1 0 1 1 0 0;0 0 0 0 1 1 0 1 1 0;0 0 0 0 0 1 1 0 1 1;0 0 0 0 0 0 1 1 0 1;0 0 0 0 0 0 0 1 1 0];
L = D-A;
H = 1/(s+L*sysx);
K = H*x0;
[y,t] = impulse(K)
The output y is null (K seems to have blown up) Somehow, this doesn't add up. I'm wondering what went wrong now.
If you do:
K = H*x0;
Num = K.Numerator
Den = K.Denominator
you will see the problem. I have no suggestions as to how to solve it.

Sign in to comment.

More Answers (0)

Categories

Find more on Oil, Gas & Petrochemical 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!