|
[求助]
用lsqnonlin拟合已知活度系数模型,残差大,无法获得最优解,请大神看看代码的问题!已有2人参与
求助各位大神!!!
小虫妹在拟合已知NRTL模型时(如图片),用matlab中最小二乘法来拟合实验数据,以求得模型中的两个参数△g12,△g21,目标方程设为OF。
编入的代码如下,运行之后,输出如下,感觉残差值比较大,拟合值好像是局部最优解,而不是全局最优; 改变初始值,对参数值的影响也很大,
初始值的设置也是个难题。
请大神看看,问题该如何解决???
另求版内大神是否有高版本1stOp能否代跑一下,给出个初值或者最优解,小虫妹不胜感激,可追加金币!!!
function OF=ObjFunBinary(x) %目标函数
format long
T=[278.15,283.15,288.15,293.15,298.15,303.15,308.15,313.15,318.15];
x1=[0.01217,0.01457,0.01704,0.02085,0.02337,0.02707,0.03041,0.03377,0.03766];
x2=1-x1;
R=8.3145;
H=19.76;
Tm=454.8;
gamma_exp=exp(H/R*(1/Tm-1./T))./x1;
a=x(1);g1=x(2);g2=x(3);%x(1)根据文献一般取0.2、0.3或者0.47
t12=g1./(R*T);
t21=g2./(R*T);
G12=exp(-a.*t12);
G21=exp(-a.*t21);
lngama1=x2.^2.*(t21.*G21.^2./(x1+x2.*G21).^2+t12.*G12./(x2+x1.*G12).^2);
gamma_cal=exp(lngama1);
OF=gamma_cal-gamma_exp;
beta0 = [0.31 2000 8000]; %参数初始值
options.Algorithm = 'levenberg-marquardt';
[beta,resnorm,residual,exitflag,output]=lsqnonlin(@ObjFunBinarynew,beta0,[],[],options)
输出的结果是
Local minimum possible.
lsqnonlin 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.
<stopping criteria details>
beta =
1.0e+04 *
0.000044925534703 1.158249518250641 1.085523151964263
resnorm =
3.233501964174955
residual =
Columns 1 through 7
-0.835682305165847 0.375853525304237 0.641305366330478 0.765737066136275 0.366439803004162 0.007880991932048 -0.337551041065019
Columns 8 through 9
-0.624403280363090 -0.870680738315109
exitflag =
3
output =
iterations: 37
funcCount: 168
stepsize: 23.651354916984875
cgiterations: []
firstorderopt: 0.093957635054323
algorithm: 'levenberg-marquardt'
message: 'Local minimum possible.
lsqnonlin stopped because the final change in the sum of squares relative to
its initial value...'
1305562_1333620757_902.jpg |
|