Laplace Inverse Transform Error

5 vues (au cours des 30 derniers jours)
Carlos
Carlos le 26 Avr 2020
Modifié(e) : Carlos le 29 Sep 2021
In a script I've got this code:
syms s t
X1 = 1/s;
syms K p Kp taud taui
num = (Kp*K*taud)*(s^2 + s/taud + 1/(taud*taui));
den =s^2 *(s+p) + K*Kp*taud * (s^2 + s/taud+ 1/(taud*taui));
H = num/den;
Y1 = H* X1;
yaux=ilaplace(Y1);
y = matlabFunction(yaux);
It returned an error in the last line that I couldn't solve. When I use a H system less complex it works, but with this H the error it returns is the following:
Error using symengine
Code generation failed due to unexpected object of type 'RootOf'.
Error in sym/matlabFunction>mup2mat (line 404)
res = mupadmex('symobj::generateMATLAB',r.s,ano,spa,0);
Error in sym/matlabFunction>mup2matcell (line 374)
r = mup2mat(c{1},true,sparseMat);
Error in sym/matlabFunction (line 188)
body = mup2matcell(funs, opts.Sparse);
Error in Untitled (line 285)
y = matlabFunction(yaux);
Please, Could someone give me a hand?
I used matlabFunction() because I need to plot the y(t) funtion and without using it, it doesn't work.
  2 commentaires
Asvin Kumar
Asvin Kumar le 29 Avr 2020
I am unsure of the exact cause of your error but I might be able to provide an alternate approach. Try using subs to substitute the values of all constants in 'yaux' and then plotting it using fplot, fsurf or other related functions.
Carlos
Carlos le 21 Mai 2020
I added the soluton I used.
Thank you for your help!

Connectez-vous pour commenter.

Réponse acceptée

Carlos
Carlos le 21 Mai 2020
Modifié(e) : Carlos le 29 Sep 2021
Hello again!
Finaly I solved it using an alternative toolbox because I couldnt be solved by other way. First of all, you need the Control System Toolbox.
This can solution can be used with every H(s) funtion if you have x(t) and you want to calculate y(t).
This is the code:
K=1000;
Kp = 1;
p = 5;
t=0:0.001:5; % set the time you want to plot
u1 = t %set the funtion ramp X(s)= 1/s^2
u2=t.^2; %set the funtion parabole X(s)= 1/s^3
Hnum = Kp*K; % vector [a*s^0]
Hden = [1 p Kp*K]; % vector [a*s^2 b*s^1 c*s^0]
y0 = step(Hnum,Hden,t); %step solution
y1 =lsim(HNum,Hden,u1,t); %ramp solution
y2 =lsim(HNum,Hden,u2,t); %parabole solution
figure(1)
plot(t,y0)
figure(2)
plot(t,y1)
figure(3)
plot(t,y2)

Plus de réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!