function dx=cetacean(t,x)x(1)=5000;x(2)=70000;r1=0.05;r2=0.08;N1=150000;N2=400000;z1=0.3;z2=0.5;%z1:长须鲸的环境竞争力,z2:蓝鲸的的环境竞争力a1=r1;a2=r2;b1=r1/N1;b2=r2/N2;c1=r1*z1/N2;c2=r2*z2/N1;dx=zeros(2,1);dx(1)=x(1)*(a1-b1*x(1)-c1*x(2));dx(2)=x(2)*(a2-b2*x(2)-c2*x(1));[t1,x]=ode45('cetacean',[0 100],[5000;70000]);plot(t1,x(:,1),'+',t1,x(:,2),'*')title('100年内,蓝鲸和长须鲸数量的变化');xlabel('时间 t');ylabel('数量 x');legend('蓝鲸''长须鲸');[t2,x]=ode45('cetacean',[51 150 ],[5000;70000]);[t3,x]=ode45('cetacean',[151 300 ],[5000;70000]);figure (9)subplot(2,3,1), plot(t1,x(:,1)),subplot(2,3,2), plot(t2,x(:,1)),subplot(2,3,3), plot(t3,x(:,1)),subplot(2,3,4), plot(t1,x(:,2)),subplot(2,3,5), plot(t2,x(:,2)),subplot(2,3,6), plot(t3,x(:,2)),有如下错误:??? Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N)to change the limit. Be aware that exceeding your available stack space cancrash MATLAB and/or your computer.Error in ==> C:/MATLAB6p5/toolbox/matlab/funfun/ode45.mOn line 155 ==> [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, args, ...》》我该怎么办。。。试过很多方法了。。
不是提示用set(0,'RecursionLimit',N)命令了吗你的矩阵太大,超过了极限,你可以从新设置这个限制,如你的函数头一句加上set(0,'RecursionLimit',71000); Be aware that exceeding your available stack space can crash MATLAB and/or your computer:小心超过你计算机能给matlab分配的可用堆栈数量matlab默认的矩阵大小限制是500,防止有的计算机内存不存大矩阵而溢出,如果出现很大的矩阵,就提示程序这可能有错,如你的程序中的70000是不是7000 |
|