Laplace Inverse Transform Error

5 ビュー (過去 30 日間)
Carlos
Carlos 2020 年 4 月 26 日
編集済み: Carlos 2021 年 9 月 29 日
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 件のコメント
Asvin Kumar
Asvin Kumar 2020 年 4 月 29 日
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 2020 年 5 月 21 日
I added the soluton I used.
Thank you for your help!

サインインしてコメントする。

採用された回答

Carlos
Carlos 2020 年 5 月 21 日
編集済み: Carlos 2021 年 9 月 29 日
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)

その他の回答 (0 件)

製品

Community Treasure Hunt

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

Start Hunting!