数学建模笔记——matlab的logistic模型
已知美国1790 1800 …到2000年人口,用logistic模型预测2010年人口数:
x向量(列向量)为1790 1800 …到2000年人口:
x=[3.9;5.3;7.2;9.6;12.9;17.1;23.2;31.4;38.6;50.2;62.9;76.0;92.0;106.5;123.2;131.7;150.7;179.3;204.0;226.5;251.4;281.4];
t为时间向量(列向量):
t=[1790:10:2000]’;
MATLAB代码:
t0=t(1); x0=x(1);
fun=@(cs,td)cs(1)./(1+(cs(1)/x0-1)exp(-cs(2)(td-t0)));
cs=lsqcurvefit(fun,rand(2,1),t(2:end),x(2:end),zeros(2,1))
xhat=fun(cs,[t;2010])
得
cs =
342.4395 (Xm)
0.0274 (r)
xhat =
3.9000
5.1086
6.6844
8.7336
11.3898
14.8179
19.2180
24.8255
31.9078
40.7513
51.6382
64.8088
80.4098
98.4348
118.6704
140.6678
163.7587
187.1247
209.9081
231.3337
250.8076
267.9671
282.6788
(预测的已知年代和2010年人口)