Error using inlineeval (line 14)

7 visualizaciones (últimos 30 días)
Dexter
Dexter el 8 de Abr. de 2021
Respondida: Steven Lord el 8 de Abr. de 2021
I am trying to differentiate a symbolic function and I get Error using inlineeval (line 14) and then error inline/subref (line 23) INLINE OUT=..
This is my code
syms m1 m2 m3 l1 l2 l3 lc1 lc2 lc3 Ic1 Ic2 Ic3 th1 th2 th3 th1_dot th2_dot th3_dot g
L=inline('(1/2*m1*lc1^2 + 1/2*Ic1*th1_dot^2 + 1/2*m2*(l1^2 + lc2^2 * (th1_dot+th2_dot)^2 +2*l1*lc2*(th1_dot+th1_dot*th2_dot)*cos(th2)) + 1/2*Ic2(th1_dot+th2_dot)^2 + 1/2*m3*(2*l1*l2*cos(th2)*th1_dot*(th1_dot+th2_dot)+ l1^2 * th1^2 +2*l1*lc3*cos(th2+th3)*th1_dot(th1_dot+th2_dot+th3_dot)+ l2^2 *(th1_dot+th2_dot)^2 +2*l2*lc3 *cos(th3)*(th1_dot+th2_dot)*(th1_dot+th2_dot+th3_dot)+lc3^2 *(th1_dot+th2_dot+th3_dot)^2) + 1/2 * Ic3*(th1_dot+th2_dot+th3_dot)-m1*g*lc1*sin(th1)-m2*g*(l1*sin(th1)+lc2*sin(th1+th2)) - m3*g*(l1*sin(th1)+l2*sin(th1+th2)+lc3*sin(th1+th2+th3))','m1','m2', 'm3', 'l1', 'l2', 'l3', 'lc1', 'lc2', 'lc3', 'Ic1', 'Ic2', 'Ic3', 'th1', 'th2', 'th3', 'th1_dot', 'th2_dot', 'th3_dot', 'g')
part_1=diff(L(m1,m2,m3,l1,l2,l3,lc1,lc2,lc3,Ic1,Ic2,Ic3,th1,th2,th3,th1_dot,th2_dot,th3_dot,g),th1)

Respuesta aceptada

Steven Lord
Steven Lord el 8 de Abr. de 2021
Do not use inline. We first marked it "not recommended" somewhere between 15 and 20 years ago if I recall correctly.
Just operate on the symbolic variables, like:
syms x y
f = x.^2 + 2*y.^3
f = 
diff(f, x)
ans = 
diff(f, y)
ans = 

Más respuestas (0)

Categorías

Más información sobre Symbolic Math Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by