怎么用matlab求解Logistic模型中的三个参数

2024-11-18 18:39:06
推荐回答(2个)
回答1:

给你这个实例,来说明如何用matlab求解Logistic模型中的三个参数。

x=[21 24 27 30 33 36 39 42 45 48];  %已知数值

y=[0 4.5541 11.5836 19.9043 22.7024 25.2441 26.2109 26.5693 26.6396 25.9511]; %已知数值

fun=inline('a(1)./(1+exp(a(2)-a(3).*x))','a','x');  %定义Logistic模型函数

a0=[0.95717  0.48538  0.80028]; %a的初值

a = nlinfit(x,y,fun,a0);  %求解Logistic模型中的三个参数

syms x

fx=vpa(fun(a,x),5);

str1=['拟合曲线f(x):',char(fx)];

fprintf('%s\n',str1)  %显示Logistic模型函数

运行结果

回答2:

建立m函数文件存为logistic1
function f=logistic1(b)
t=[0,5,10,24,33,48,57,72,96,120,144,168,192,216];y=[0,0.028,0.103,0.336,0.450,0.597,0.716,0.778,0.835,0.849,0.816,0.839,0.811,0.816];
f = y-b(1)./(1+b(2).*exp(-b(3).*t));
b0=[10,2,2];
>> b=leastsq('logistic1',b0)
b =
0.8221 13.9173 0.0818
或者cftool
General model:
f(x) = b/(1+a*exp(-k*x))
Coefficients (with 95% confidence bounds):
a = 13.92 (6.301,21.53)
b = 0.822 (0.7911,0.853)
k = 0.08184 (0.06479,0.0989)
Goodness of fit:
SSE:0.01404
R-square:0.9898
Adjusted R-square:0.9879
RMSE:0.03572