Getting an error while using ODE45 with an anonymous function created from a griddedInterpolant
6 次查看(过去 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!