Getting an error while using ODE45 with an anonymous function created from a griddedInterpolant
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Walter Roberson
le 25 Sep 2019
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)
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!