ODE45 - problem with parameters passed in odefcn

10 vues (au cours des 30 derniers jours)
JV
JV le 6 Mar 2021
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.

Réponse acceptée

Cris LaPierre
Cris LaPierre le 6 Mar 2021
Modifié(e) : Cris LaPierre le 6 Mar 2021
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
  1 commentaire
JV
JV le 6 Mar 2021
Works as planned. Thank you Sir!

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by