菜鳥求助 !!
程序很简单就是总是出现Index exceeds matrix dimensions.高手請看看
i=1:60;
t=1;
a(i)=4;
b(i)=4;
-100<i<100
while t<2400;
if i+1>60 a(i+1)=4; b(i+1)=4;end
if i-1<1 a(i-1)=4; b(i-1)=4;end
if a(i)<0;a(i)=0; end
a(i)=0.03125.*(16-a(i).*b(i))+0.25*(a(i+1)+a(i-1)-2.*a(i));
b(i)=0.03125.*(a(i).*b(i)-b(i)-12)+0.0625.*(b(i+1)+b(i-1)-2.*b(i));
t=t+1;
end
plot(i,a);xlabel('i');ylabel('a');