Getting an error while using ODE45 with an anonymous function created from a griddedInterpolant
4 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I'm trying to integrate an array using ode45 representing acceleration. Because the array is not a function, i used griddedInterpolant in order to interpolate the values of the function. The problem is that when i try to use ODE 45 with the recently created anonymous function i get the following error:
Is there a way to fix this error? or is threre any other way of realizing this numeric integral? I already tried using euler method (ODE1) but the answer doesn't converge, and other functions such as cumtrapz doesn't work either.
Thanks in advance for any help.
t=1:223
F=griddedInterpolant(t,qdd(:,1));
fun=@(i) F(i)
t0=0
tfinal=223
y0=qd(1,1)
y=ode45(fun,[t0 tfinal],y0)
Error using @(i)F(i)
Too many input arguments.
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);
2 件のコメント
Walter Roberson
2019 年 9 月 25 日
ode45 always passes two arguments to the function. You do not have to use them, but you have to accept them.
fun = @(t,y) F(t)
回答 (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!