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!