roumots 发表于 2007-5-5 10:11

最小二乘拟合的问题??

今天做了一个拟合的题目,用的是lsqnonlin,matlab提示如下:

Optimization terminated: directional derivative along
search direction less than TolFun and infinity-norm of
gradient less than 10*(TolFun+TolX).
Optimization terminated: directional derivative along
search direction less than TolFun and infinity-norm of
gradient less than 10*(TolFun+TolX).

我的代码如下,请问怎么回事情啊??

function exam74
x=;
y=;
r=;
x0=;
opt1=optimset('LargeScale','off','MaxFunEvals',1000);
opt2=optimset(opt1,'LevenbergMarquardt','off');
=lsqnonlin(@rget,x0,[],[],opt1,x,y,r);
=lsqnonlin(@rget,x0,[],[],opt2,x,y,r);

function f=rget(xx,x,y,r)
for i=1:12
    f(i)=sqrt((x(i)-xx(1))^2+(y(i)-xx(2))^2)/r(i);
end

roumots 发表于 2007-5-5 10:15

题目的意思是给定12个坐标,求与他们的距离和最小的那个点的坐标!

branch 发表于 2007-5-5 17:02

回复 #2 roumots 的帖子

非线性最优化问题,不会,期待高手解答!!
页: [1]
查看完整版本: 最小二乘拟合的问题??