声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1008|回复: 2

[综合讨论] 最小二乘拟合的问题??

[复制链接]
发表于 2007-5-5 10:11 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
今天做了一个拟合的题目,用的是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=[0 8.20 0.50 5.70 0.77 2.87 4.43 2.58 0.72 9.76 3.19 5.55];
y=[0 0.50 4.90 5.00 6.49 8.76 3.26 9.32 9.96 3.16 7.20 7.88];
r=[600 1000 800 1400 1200 700 600 800 1000 1200 1000 1100];
x0=[0,0];
opt1=optimset('LargeScale','off','MaxFunEvals',1000);
opt2=optimset(opt1,'LevenbergMarquardt','off');
[site1,norm2,res3]=lsqnonlin(@rget,x0,[],[],opt1,x,y,r);
[site1,norm2,res3]=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
回复
分享到:

使用道具 举报

 楼主| 发表于 2007-5-5 10:15 | 显示全部楼层
题目的意思是给定12个坐标,求与他们的距离和最小的那个点的坐标!
发表于 2007-5-5 17:02 | 显示全部楼层

回复 #2 roumots 的帖子

非线性最优化问题,不会,期待高手解答!!
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-24 15:25 , Processed in 0.055887 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表