是模型的问题吗?为什么拟合效果差这么远,这是一个人口问题

clear
t=1:1:20;
N=[4751 4788 4822 4857 4889 4660 4719 4768 4816 4858 4610 4655 4694 4731 4770 4811 4857 4970 4947 4982];
plot(t,N,'o');hold on;
fun=@(c,x) c(3)./(1+(c(1)-1)*exp(-c(2)*x));
c0(1)=2000/4751;c0(2)=mean(diff(N)./diff(t)./N(1:19));c0(3)=2005;
e0=sum((N- fun(c0,t)).^2)

e0 =

1.3586e+06

tt=[20,21];NN0= fun(c0,tt)

NN0 =

1.0e+03 *

4.4445    4.4301

[c,e]=lsqcurvefit(fun,c0,t,N)

Local minimum possible.

lsqcurvefit stopped because the final change in the sum of squares relative to
its initial value is less than the default value of the function tolerance.

c =

1.0e+03 *

0.0010   -0.0004    4.7589

e =

1.1308e+05

plot(t, fun(c,t),'r');
NN=fun(c,tt)

NN =

1.0e+03 *

5.0223    5.1642

plot(tt,NN,'r*');title('logistic');hold off;

img

是你的原始数据有问题,你看那些离散的点,并不符合你的模型规律,而是看起来像三条直线

建立人口模型一般数据是按照时间顺序进行排列的,一般情况下是递增的,你的数据应该是没有整理过的,建议查看一下原始数据或者看下数据是否复制错误