ODE45 - problem with parameters passed in odefcn
9 ビュー (過去 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.
0 件のコメント
採用された回答
Cris LaPierre
2021 年 3 月 6 日
編集済み: Cris LaPierre
2021 年 3 月 6 日
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
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Ordinary Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!