In need of help with ODE45 & Index exceeds matrix dimensions, error problem
1 次查看(过去 30 天)
显示 更早的评论
I am trying to plot a graph for LKE model.
It gives the following errors:
Index exceeds matrix dimensions.
Error in SeasonalityLKE/LKEModel (line 39)
yp(1) = b*y(1)*(1-y(1)/(min(y(3),(P-theta*y(2))/q)))-(c*y(1))/(a+y(1))*y(2);
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);
Error in SeasonalityLKE (line 22)
[t,y]=ode45(@LKEModel,[0 80],[.5; .25]);
0 个评论
采纳的回答
Walter Roberson
2017-9-9
Your call
[t,y]=ode45(@LKEModel,[0 80],[.5; .25]);
indicates that the initial conditions for y are [.5; .25] which is a vector of length 2.
Your LKEModel code has
yp(1) = b*y(1)*(1-y(1)/(min(y(3),(P-theta*y(2))/q)))-(c*y(1))/(a+y(1))*y(2);
which uses y(3) which implies that your need at least three initial conditions.
更多回答(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!