如何进行圆拟合?
我有近似的圆上一批点,想把他拟合成圆?如何做?找了一下,有一个matlab中的,可惜matlab不会,
===================================
7)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.