Strange result in ilaplace()

Hi! I'm trying to make inverse laplace transform, but clearly the result is wrong because the expression don't even has the time variable. Could someone help me?
syms Kp Ki Kd s time
plant = 1/(s^3 + 9*s^2 + 23*s + 15);
controler = Kp + Kd*s + Ki/s;
system_laplace = simplify((plant * controler)/(1 + plant * controler));
system_time = ilaplace(system_laplace, s, time)

 Accepted Answer

It’s not strange. It’s just that you have a transfer function that’s not possible to invert. Just before the ilaplace call, I added:
system_laplace = partfrac(system_laplace, s, 'FactorMode', 'full')
since that can allow inversion in situations where ilaplace otherwise fails. It didn’t work with your system.
You probably need to do your analysis in the Control System Toolbox. See the documentation for the tf function, since it will allow you to enter your equations as you have entered them here:
  • s = tf('s') to specify a TF model using a rational function in the Laplace variable, s.

7 Comments

My main objetive was to find the error expression in time. To do this I have to do the inverse laplace. I'll read the control documentation.
Thanks !
My pleasure.
It’s much easier to do this numerically with a range of values. To do it symbolically, constraining your parameters by stating them all as real, or with the assume function, could help, but inverting a function with a fourth-degree denominator and a third-degree numerator could be a challenge. That’s the reason I hoped partfrac would help, but it produced a symsum with four summations.
It might be worthwhile to try another symbolic solver, such as Wolfram (free online) to see if it can invert it. I didn’t think about that last night.
The ilaplace does work, time is there. I prepared a longish response but the system went down for maintenance for a number of hours so I have not had a chance to post it. I will do that later.
I agree that a numerical solution would be much easier, but I need the error expression to find the ITAE, that evaluates the system performance. I already did the inverse laplace by hand without a computer, but It was so big that I can made a mistake somewere.
My intention was to make a script to find ITAE to a given plant and pid controller.
I gave it a shot with Wolfram Alpha (link) just now and it gave me an ‘Invalid value’ error for the simplify output:
(Kd*s^2 + Kp*s + Ki)/(Ki + 15*s + Kp*s + Kd*s^2 + 23*s^2 + 9*s^3 + s^4)
I’m linking to it with your equation so you can have a go at it.
I need to install Maple on my other machine (also with R2016b) since I prefer it. I need to keep MuPad on this one to answer Questions here. I’ll do that in a few hours (just now waking up here) and reply here with a solution if Maple provides one.
I guess would be bether break the expression in parts and calculate they separately.
Thanks for all help that you all gave me!
Our pleasure!

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 12 Feb 2017
Answer is in the attached file (too large to paste content on my phone)

11 Comments

Daniel Caliari
Daniel Caliari on 12 Feb 2017
Edited: Daniel Caliari on 12 Feb 2017
That's a pretty big expression!
How did you find it?
Thanks for it, but I need the matlab script.
My guess is Maple.
@Walter — If you got that from the Symbolic Math Toolbox, please share your secret!
In R2016b, the solution given is
Kp*symsum((root(s3^4 + 9*s3^3 + Kd*s3^2 + 23*s3^2 + 15*s3 + Kp*s3 + Ki, s3, k)*exp(root(s3^4 + 9*s3^3 + Kd*s3^2 + 23*s3^2 + 15*s3 + Kp*s3 + Ki, s3, k)* time )) / (Kp + 46*root(s3^4 + 9*s3^3 + Kd*s3^2 + 23*s3^2 + 15*s3 + Kp*s3 + Ki, s3, k) + 27*root(s3^4 + 9*s3^3 + Kd*s3^2 + 23*s3^2 + 15*s3 + Kp*s3 + Ki, s3, k)^2 + 4*root(s3^4 + 9*s3^3 + Kd*s3^2 + 23*s3^2 + 15*s3 + Kp*s3 + Ki, s3, k)^3 + 2*Kd*root(s3^4 + 9*s3^3 + Kd*s3^2 + 23*s3^2 + 15*s3 + Kp*s3 + Ki, s3, k) + 15), k, 1, 4) + Kd * symsum((exp(root(s3^4 + 9*s3^3 + Kd*s3^2 + 23*s3^2 + 15*s3 + Kp*s3 + Ki, s3, k)* time ) * root(s3^4 + 9*s3^3 + Kd*s3^2 + 23*s3^2 + 15*s3 + Kp*s3 + Ki, s3, k)^2) / (Kp + 2*Kd*root(s3^4 + 9*s3^3 + Kd*s3^2 + 23*s3^2 + 15*s3 + Kp*s3 + Ki, s3, k) + 27*root(s3^4 + 9*s3^3 + Kd*s3^2 + 23*s3^2 + 15*s3 + Kp*s3 + Ki, s3, k)^2 + 4*root(s3^4 + 9*s3^3 + Kd*s3^2 + 23*s3^2 + 15*s3 + Kp*s3 + Ki, s3, k)^3 + 46*root(s3^4 + 9*s3^3 + Kd*s3^2 + 23*s3^2 + 15*s3 + Kp*s3 + Ki, s3, k) + 15), k, 1, 4) + Ki * symsum(exp(root(s3^4 + 9*s3^3 + Kd*s3^2 + 23*s3^2 + 15*s3 + Kp*s3 + Ki, s3, k)* time ) / (Kp + 2*Kd*root(s3^4 + 9*s3^3 + Kd*s3^2 + 23*s3^2 + 15*s3 + Kp*s3 + Ki, s3, k) + 27*root(s3^4 + 9*s3^3 + Kd*s3^2 + 23*s3^2 + 15*s3 + Kp*s3 + Ki, s3, k)^2 + 4*root(s3^4 + 9*s3^3 + Kd*s3^2 + 23*s3^2 + 15*s3 + Kp*s3 + Ki, s3, k)^3 + 46*root(s3^4 + 9*s3^3 + Kd*s3^2 + 23*s3^2 + 15*s3 + Kp*s3 + Ki, s3, k) + 15), k, 1, 4)
This does have time in it. Look at the exp() parts: exp(root(SOMETHING)*time)
You can extract the root(s3^4 + 9*s3^3 + Kd*s3^2 + 23*s3^2 + 15*s3 + Kp*s3 + Ki, s3, k) part and get the roots:
syms s3
SSS = solve(s3^4 + 9*s3^3 + Kd*s3^2 + 23*s3^2 + 15*s3 + Kp*s3 + Ki, s3), 'MaxDegree', 4);
and then you can carefully substitute that into the expression.
I used Maple to get the inverse laplace as a sum over roots, and then I asked Maple to allvalues() to expand the quartic. The rest was formatting.
The full expression is what I included in the file, and it is MATLAB code. You just have to syms the appropriate names into existence. Oh, and you will need to either join it all together into one line or else put ... continuation operators on it.
@Walter — Thank you for the explanation.
That settles it. I’m putting Maple on my other (newer) laptop.
Hello!
I am trying to do this using MAPLE to get the symbolic expression of my laplacian function ( https://es.mathworks.com/matlabcentral/answers/2029559-how-could-i-calculate-the-correct-laplace-inverse-using-ilaplace ).
Could you please attach the code you used in MALP to get the result in the txt file?
Thanks in advance.
In Maple, you could use FileTools[Text][Open] and FileTools[Text][WriteString] but I personally am a lot more likely to use fopen() and writeline()
... and then to get the kind of output I posted here, I would typically follow that up by editing the file in a decent editor such as vim and doing substitutions using regular expressions to introduce strategic spaces for readability.
Sir,I sincerely ask for your help, as I have the same problem. When solving the inverse Laplace transform, I obtained some expressions about ‘root’, but I hope to get a practical solution, even if it is very complex and long.
Here is my code:
syms s kp ki v t w
v = 220*sqrt(2);
num = w*v*kp*s + w*v*ki;
den = s^3 + w*s^2 + w*v*kp*s+w*v*ki;
G = num/den;
G_1 = G*(100*pi/s);
ilaplace(G_1)
ans = 
In this code, kp, ki, and w are unknowns, as symbols. I need to perform an inverse Laplace transform on G_1. I saw that you gave a specific, very long time-domain expression above, which is the result I hope to get. Unfortunately, after reading your several answers, I didn’t understand how you operated. I even downloaded Maple for this, but as a beginner, I don’t understand how to use Maple to solve it. I urgently need your help. If you can help me, I will be very grateful!
Sorry, I am away from my desk for several days, and do not have easy access to my tools.
In relatively recent releases, you can
iG_1 = ilaplace(G_1);
rewrite(rewrite(iG_1, "symsum"), "expandroot")
Hi @乐天,
Considering that the inverse Laplace transform 'ilaplace()' needs to account for the general response of the 3rd-order system, it is important to note that this may result in having one real eigenvalue and two complex eigenvalues. These complex eigenvalues indicate a linear combination of sine and cosine functions, resulting in an oscillating response. Consequently, the analytical solution in the time-domain can be lengthy and complex.
However, if the design parameters are carefully chosen to ensure that the 3rd-order system produces 3 real eigenvalues, you will be delighted to see a more concise and compact analytical solution.
By the way, this syntax produces an error message.
syms s kp ki v t w
v = 220*sqrt(2);
num = w*v*kp*s + w*v*ki;
den = s^3 + w*s^2 + w*v*kp*s+w*v*ki;
G = num/den;
G_1 = G*(100*pi/s);
iG_1 = ilaplace(G_1)
rewrite(rewrite(iG_1, "expandsum"), "expandroot")

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!