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;