Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
|
![]() |
#1 |
初级会员
注册日期: 2012-09-19
年龄: 37
帖子: 1
声望力: 0 ![]() |
![]()
求解一个优化问题 采用lsqnonlin函数
编写的一个函数m文件如下: function F=myfun3(a) i=1:5; mi=[0.0686,1.0714,0.0714,3.2445,-0.0798]; syms x; t=a(1)*x+a(2)*x^2+a(3)*x^3+a(4)*x^4+a(5)*x^5; f=(1+t+t^2/2+t^3/6+t^4/24+t^5/120); F=1-int(x.^i*f,x,-3,3)/mi*(int(f,x,-3,3)); 然后再命令窗口输入 如下命令: >> a0=[0,0,0,0,0]; >> [a,resnorm]=lsqnonlin(@myfun3,a0) 然后运行 结果出现一堆看不懂的问题: 好几个warning 如 Warning: System is inconsistent. Solution does not exist. > In sym.mldivide at 32 In sym.mrdivide at 27 In myfun3 at 7 In optim\private\lsqncommon at 88 In lsqnonlin at 163 还有如下错误 ??? Function 'lt' is not defined for values of class 'sym'. Error in ==> optim\private\nlsq at 329 if (GradF'*SD) < tolFun && ... Error in ==> optim\private\lsqncommon at 216 [x,FVAL,JACOB,EXITFLAG,OUTPUT,msg] = ... Error in ==> lsqnonlin at 163 [x,Resnorm,FVAL,EXITFLAG,OUTPUT,LAMBDA,JACOB] = ... matlab不是很懂,麻烦高人看看我的程序怎么改,谢谢 |
![]() |
![]() |