MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [MATLAB数学相关] 非线性最小二乘法 lsqnonlin函数 程序遇到问题 (https://www.labfans.com/bbs/showthread.php?t=17778)

watchdog 2012-09-20 18:08

非线性最小二乘法 lsqnonlin函数 程序遇到问题
 
求解一个优化问题 采用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不是很懂,麻烦高人看看我的程序怎么改,谢谢


所有时间均为北京时间。现在的时间是 12:37

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.