problem with reduceDifferentialOrder -> massMatrixForm -> odeFunction
1 次查看(过去 30 天)
显示 更早的评论
Hello.
I am trying to get the Euler-Lagrange equation for a mechanical system and to integrate them numerically. The code is pasted below.
What I get is an error message from 'odeFunction'
Error using mupadengine/feval (line 163) The parameter 'diff(phi(t), t)' is invalid.
Error in sym/odeFunction (line 118) A = feval(symengine, 'daetools::odeFunction', expr, vars, params{:});
I do not understand this error as, at least explicitly, the derivatives diff(phi(t),t), etc are not present neither in M nor in F.
Thank you. Best regards.
syms R L0 m g real
for s = [R L0 m g]
assume(s>0);
end
syms phi(t)
%phi(t) = (L0-s(t))/R;
urho = [ cos(phi), sin(phi)];
uphi = [-sin(phi), cos(phi)];
ux = sym([1 0]);
uy = sym([0 1]);
syms l2(t)
%
r1 = R*urho + (L0-l2-phi*R)*uphi;
r2 = R*ux - l2*uy;
v1 = diff(r1,t);
v2 = diff(r2,t);
T = sym(1/2)*m*( simplify(v1*v1.'+v2*v2.'));
V = (m*g*r1+m*g*r2)*(uy.');
L = T-V;
eqnizq = simplify(functionalDerivative(L,[phi l2]) );
eqn = eqnizq == 0;
[newEqs, newVars, R] = reduceDifferentialOrder(eqn, [phi(t) l2(t)]);
[M,F] = massMatrixForm(newEqs,newVars);
Mn = odeFunction(M, newVars, m,g,R,L0)
Fn = odeFunction(F, newVars, m,g,R,L0)
0 个评论
回答(2 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Special Values 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!