| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1352 人关注过本帖
标题:[求助]怎样实现圆的拟合?
只看楼主 加入收藏
syden11
Rank: 1
等 级:新手上路
帖 子:15
专家分:0
注 册:2007-4-12
收藏
 问题点数:0 回复次数:2 
[求助]怎样实现圆的拟合?
  若要将得到的数组进行圆的拟合,改用什么程序编写呢?请大家帮帮我吧 ,最好有具体的程序,谢谢..
搜索更多相关主题的帖子: 拟合 
2007-06-20 19:58
abingchem
Rank: 6Rank: 6
等 级:贵宾
威 望:24
帖 子:716
专家分:0
注 册:2004-12-30
收藏
得分:0 

一段文章,供参考:
Matlab中如何作圆回归?
:#Peter Boettcher (boettcher@ll.mit.edu),2002/5/16, comp.soft-sys.matlab#

Q5.5: How can I fit a circle to a set of XY data?
=================================================

An elegant chunk of code to perform least-squares circle fitting was
written by Bucher Izhak and has been floating around the newgroup for
some time. The first reference to it that I can find is in:

function [xc,yc,R,a] = circfit(x,y)
%CIRCFIT Fits a circle in x,y plane
%
% [XC, YC, R, A] = CIRCFIT(X,Y)
% Result is center point (yc,xc) and radius R.A is an optional
% output describing the circle's equation:
%
% x^2+y^2+a(1)*x+a(2)*y+a(3)=0

% by Bucher izhak 25/oct/1991

n=length(x); xx=x.*x; yy=y.*y; xy=x.*y;
A=[sum(x) sum(y) n;sum(xy) sum(yy) sum(y);sum(xx) sum(xy) sum(x)];
B=[-sum(xx+yy) ; -sum(xx.*y+yy.*y) ; -sum(xx.*x+xy.*y)];
a=A\B;
xc = -.5*a(1);
yc = -.5*a(2);
R = sqrt((a(1)^2+a(2)^2)/4-a(3));

Tom Davis provided a more sophisticated approach that works for more
cases in and Code included.


此人已消失
2007-06-20 22:18
ydgsl
Rank: 3Rank: 3
等 级:论坛游民
威 望:8
帖 子:107
专家分:20
注 册:2006-9-20
收藏
得分:0 
回复:(syden11)[求助]怎样实现圆的拟合?
一个实例:
x=[38.849, 37.706, 31.188, 20.238, 6.8660, -6.5940, -18.056, -26.135, -30.328, -30.814, -28.035, -22.542, -14.782, -5.2590, 5.4750, 16.587, 26.893, 34.852];
y=[ 0., 13.724, 26.107, 35.053, 38.934, 37.402, 31.276, 21.931, 11.039, .100e-2, -10.204, -18.915, -25.603, -29.825, -31.049, -28.729, -22.565, -12.684];
b=[35.06010729, 4.016838807, .2587265862e-2]
x1=linspace(min(x)-1,max(x)+.5,120);
y1=sqrt(b(1)*b(1)-(x1-b(2)).^2)+b(3)+4;
plot(x,y,'o','markerfacecolor','k','markeredgecolor','k','markersize',8)
hold on
plot(x1,y1,'b-','linewidth',3)
y2=-sqrt(b(1)*b(1)-(x1-b(2)).^2)+b(3)+4;
plot(x1,y2,'b-','linewidth',3)
plot(b(2),4+b(3),'or','markerfacecolor','r','linewidth',2)
axis tight
在本例中,b(2)=4.0168,4+b(3)=4.0026即为圆心位置,b(1)=35.06为半径。
若能提供数据,也可进行类似拟合。
2007-06-20 23:03
快速回复:[求助]怎样实现圆的拟合?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025415 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved