Error using inlineeval (line 14)

조회 수: 21 (최근 30일)
Dexter
Dexter 2021년 4월 8일
답변: Steven Lord 2021년 4월 8일
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)

채택된 답변

Steven Lord
Steven Lord 2021년 4월 8일
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 = 

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Robust Control Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by