ODE45 numel (x) = 1 error
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am trying to solve a second order ODE using ODE45. I created a function based on some examples I found:
function xp = Function(t,x)
xp = zeros(2,1);
xp(1) = x(2);
xp(2) = (-2*x(2))-(exp(-t)*x(1));
It seemed pretty basic to me but when I try to run the solver it give me this:
>> [t,x]=ode45('Function',[0,20],0)
Attempted to access x(2); index out of bounds because numel(x)=1.
Error in Function (line 3) xp(1) = x(2);
Error in odearguments (line 88) f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 114) [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
What am I doing wrong with my indexing that is holding me out from solving the equation?
0 Kommentare
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!