ODE45 - problem with parameters passed in odefcn
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponse acceptée
Cris LaPierre
le 6 Mar 2021
Modifié(e) : Cris LaPierre
le 6 Mar 2021
I found this example helpful: https://www.mathworks.com/help/matlab/ref/ode45.html#bu3uhuk
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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!