Matlab逐步Logistic人口增长模拟

时间:2018-08-17 22:25:16

标签: matlab while-loop population

我正在尝试对逻辑增长进行Matlab模拟,其中人口为树T,最大树为M。但是,除非我使用1的增长因子k,否则返回的数字为很奇怪。

T的向量结果。没有负树之类的东西。我不知道如何得到负无穷大树。

Columns 1 through 11

    0.0000    0.0000    0.0000   -0.0000   -0.0000   -0.0000   -0.0000   -0.0000   -0.0000   -1.0504      -Inf

  Columns 12 through 22

      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf

  Columns 23 through 33

      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf

  Columns 34 through 44

      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf

  Columns 45 through 55

      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf

  Columns 56 through 66

      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf

  Columns 67 through 77

      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf

  Columns 78 through 88

      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf

  Columns 89 through 99

      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf      -Inf

  Column 100

      -Inf

代码:

t= 1:1:100;
i=1;

k=0.25;
M=100;
T(1)=1;

while i<100
    T(i+1)=T(i)+k.*T(i).*(M-T(i));
    i=i+1;
end

disp(T)

plot(t,T);

1 个答案:

答案 0 :(得分:0)

defaultdict

数字T每次迭代都在增长,直到达到-infinity

defaultdict(int)