求助matlab如何拟合logistic函数模型
举个例子
数据:x=[1790 1800 1810 1820 1830 1840 1850 1860 1870 1880 1890 1900 1910 1920 1930 1940 1950 1960 1970 1980 1990 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];
用matlab程序logistic人口模型进行拟合
代码
x=[1790 1800 1810 1820 1830 1840 1850 1860 1870 1880 1890 1900 1910 1920 1930 1940 1950 1960 1970 1980 1990 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];
cf_ = fit(x,y,ft_ ,'Startpoint',st_)
ft_ = fittype('a/(1+b*exp(-k*(x-1790)))', 'dependent',{'y'},'independent',{'x'}, 'coefficients',{'a', 'b', 'k'});
cf_ = fit(x,y,ft_ ,'Startpoint',st_)
plot(x,y,'or',x,cf_(x),'-b.')
结果
cf_ =
General model:
cf_(x) = a/(1+b*exp(-k*(x-1790)))
Coefficients (with 95% confidence bounds):
a = 446.6 (371.1, 522)
b = 57.01 (48.93, 65.09)
k = 0.02155 (0.01945, 0.02365)
2024-10-28 广告