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!