ODE45 - problem with parameters passed in odefcn

10 次查看(过去 30 天)
Hello,
I encountered a problem with passing extra parameters to ode. I attached the live script file with said issue.
I'll be extremely thankful for any input.
During debbuging I saw that their values inside odefcn nonsensically differ from those that I passed inside.

采纳的回答

Cris LaPierre
Cris LaPierre 2021-3-6
编辑:Cris LaPierre 2021-3-6
I think you need to set up your odefun and call to ode45 as follows
odefun = @(t,theta) throwTraj(t,theta,v_tool,robot);
[t, theta] = ode45(odefun, 0:0.01:t_end, theta0);
This means you also need to update the function declaration for throwTraj
function dtheta = throwTraj(t,theta,v_tool,robot)
This will lead to a new error:;
Expected one output from a curly brace or dot indexing expression, but there were 7 results.
Error in forum_example>throwTraj (line 100)
J = [robot.s_hat(1)*p7,...
Error in forum_example (line 59)
odefun = @(t,theta) throwTraj(t,theta,v_tool,robot);
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
This is because you calculate J without indexing robot. You have 7 fields, so it calculates a result for each, returning 7. Everywhere else you appear to use indexing. For example
robot(1).u

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by