我把ode45放在一个循环里,然后第二步循环的时候就说这个数组越界了
while t<1000
t=t+0.1;
if K1<r & K2<j
K1=0.152*0.1+K1;
K2=K2+0.1*0.06;
cost=cost+2.12*0.1;
else if K1>=r & K2<j
op=odeset('Events',@eventfun);
[c,T,cend,Tend,evennum]=ode45(@ivpodefun,[0 20],[K1,K2],op);错误是:Attempted to access isterminal(2); index out of bounds because numel(isterminal)=1.Error in odezero (line 143)
if any(isterminal(indzc))Error in ode45 (line 353)
[te,ye,ie,valt,stop] = ...菜鸟,刚开始用Matlab
while t<1000
t=t+0.1;
if K1<r & K2<j
K1=0.152*0.1+K1;
K2=K2+0.1*0.06;
cost=cost+2.12*0.1;
else if K1>=r & K2<j
op=odeset('Events',@eventfun);
[c,T,cend,Tend,evennum]=ode45(@ivpodefun,[0 20],[K1,K2],op);错误是:Attempted to access isterminal(2); index out of bounds because numel(isterminal)=1.Error in odezero (line 143)
if any(isterminal(indzc))Error in ode45 (line 353)
[te,ye,ie,valt,stop] = ...菜鸟,刚开始用Matlab
