- clear;clc %清空所有变量,清除命令栏
- B=5; %设定B的值
- D=0.2; %设定D的值
- Dc=0.01; %设定Dc的值
- dt=0.1; %设定dt的值
- x(1)=13; %设定人口初值为13
- for n=1:100;
- x(n+1)=x(n)+dt*(B*x(n)-D*x(n)-Dc*x(n)*x(n)); %使用for循环,计算equation of differences,得到人口数量
- end
- t=dt*(0:100); %计算time
- plot(t,x) %绘制time-Population曲线
- xlabel('time') %设定图的横坐标名称
- ylabel('Population size') %设定图的纵坐标名称
- title('Population') %设定图的标题
- xn=x(1:end-1); %x的第1个数至倒数第2个数为x(n)
- xn1=x(2:end); %x的第2个数至最后一个数为x(n+1)
- figure
- plot(xn,xn1) %绘制steady states图,横坐标为x(n),纵坐标为x(n+1)
- hold on %保持当前坐标
- plot([0 600],[0 600],'r') %绘制y=x直线
- scatter(x(end-1),x(end),'k') %标出两条线的交点,用黑色圆圈表示
- xlabel('Population size at t(n)') %设定图的横坐标名称
- ylabel('Population size at t(n+1)') %设定图的纵坐标名称
- title('Graphical analysis:steady states') %设定图的标题



雷达卡




京公网安备 11010802022788号







