Error using inlineeval (line 14)

1 回表示 (過去 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 Center および File ExchangeRobust Control Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by