Clear Filters
Clear Filters

In need of help with ODE45 & Index exceeds matrix dimensions, error problem

2 views (last 30 days)
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]);

Accepted Answer

Walter Roberson
Walter Roberson on 9 Sep 2017
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.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!