圆最小二乘拟合函数
一个比较老,但管用的圆最小二乘拟合函数function = circfit(x,y)
%CIRCFIT Fits a circle in x,y plane
%
% = 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)); 例:
xd = rand(1,10);
yd = rand(1,10);
=circfit(xd,yd);
plot(xd,yd,'r*');hold on;
t=linspace(0,pi*2,100);
z=xc+yc*i+R*exp(i*t);
plot(z); axis equal; 这个好象matlab的help or demo里面已有. 原帖由 xjzuo 于 2007-10-29 10:36 发表 http://www.chinavib.com/forum/images/common/back.gif
这个好象matlab的help or demo里面已有.
没找到,请指示 这个很好
很值得学习,谢谢楼主 多谢楼主分享
页:
[1]