数学建模:logistic函数拟合(matlab代码)

x=[1790:10:2000];
y=[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];
x=x';y=y';                  % 将原始数据转换为列向量
st_ = [500 20 0.2];         % xm,b,r 设定初始值
ft_ = fittype('xm/(1+b*exp(-r*(x-1790)))','dependent',{'y'},'independent',{'x'},'coefficients',{'xm', 'b', 'r'});
cf_ = fit(x,y,ft_ ,'Startpoint',st_)
% 模型输出的拟合参数
xm = 446.6;    % 拟合出的最大人口数量xm
b = 57.01;     % b=xm/x0;
r = 0.02155;   % 拟合出的人口增长率r
% 画图       
scatter(x,y);  % 散点图
hold on;
x1=[1790:10:2300];  % 检验查看拟合曲线是否为S型曲线
cf_ = xm./(1+b*exp(-r*(x1-1790)));
plot(x1,cf_);
grid

参考资料:

https://zhidao.baidu.com/question/163154587.html

猜你喜欢

转载自www.cnblogs.com/feynmania/p/12750789.html