马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
我有如下方程,需用非线性最小二乘求解最优解,我用的是lsqnonlin,但是不管怎么迭代,都得不到最优解,运行结果在最下面。(最优解为:-0.0123,-0.5313,-0.0275,0.0032,0.0025)谁能帮我看看问题出在哪了吗?
function f = fun12(a);
fa1 =@(x)x.*exp(a(1).*x+a(2).*x.^2+a(3).*x.^3+a(4).*x.^4+a(5).*x.^5);
fa2 =@(x)exp(a(1).*x+a(2).*x.^2+a(3).*x.^3+a(4).*x.^4+a(5).*x.^5);
FA1 =quadl(fa1,-3,3);
FA2 =0.0472*quadl(fa2,-3,3)
f1 =1-FA1/FA2;
fb1 =@(x)x.^2.*exp(a(1).*x+a(2).*x.^2+a(3).*x.^3+a(4).*x.^4+a(5).*x.^5);
fb2 =@(x)exp(a(1).*x+a(2).*x.^2+a(3).*x.^3+a(4).*x.^4+a(5).*x.^5);
FB1 =quadl(fb1,-3,3);
FB2 =0.9442*quadl(fb2,-3,3)
f2 =1-FB1/FB2;
fc1 =@(x)x.^3.*exp(a(1).*x+a(2).*x.^2+a(3).*x.^3+a(4).*x.^4+a(5).*x.^5);
fc2 =@(x)exp(a(1).*x+a(2).*x.^2+a(3).*x.^3+a(4).*x.^4+a(5).*x.^5);
FC1 =quadl(fc1,-3,3);
FC2 =(-0.1419)*quadl(fc2,-3,3);
f3 =1-FC1/FC2;
fd1=@(x)x.^4.*exp(a(1).*x+a(2).*x.^2+a(3).*x.^3+a(4).*x.^4+a(5).*x.^5);
fd2 =@(x)exp(a(1).*x+a(2).*x.^2+a(3).*x.^3+a(4).*x.^4+a(5).*x.^5);
FD1 =quadl(fd1,-3,3);
FD2 = 2.5563*quadl(fd2,-3,3)
f4 =1-FD1/FD2;
fe1=@(x)x.^5.*exp(a(1).*x+a(2).*x.^2+a(3).*x.^3+a(4).*x.^4+a(5).*x.^5);
fe2 =@(x)exp(a(1).*x+a(2).*x.^2+a(3).*x.^3+a(4).*x.^4+a(5).*x.^5);
FE1 =quadl(fe1,-3,3);
FE2 = 0.5687*quadl(fe2,-3,3)
f5 =1-FE1/FE2;
f =[f1;f2;f3;f4;f5];
主程序如下:
a0 =[1.0077 -0.3031 -0.9806 -0.0841 0.1289]
options = optimset('Display','iter','MaxFunEvals',3000,'MaxIter',1000,'TolFun',1e-20);
[a,resnorm,RESIDUAL] = lsqnonlin(@fun12,a0,[],[],options)
a =
1.2477 -0.3031 -0.9806 -0.0841 0.1289
fval =
1.0e-014 *
0.2887
0.0333
-0.4885
0.0111
0.4552
|