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!