MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [求助]matlab求圆心坐标 (https://www.labfans.com/bbs/showthread.php?t=860)

tangguoge 2007-11-28 22:15

[求助]matlab求圆心坐标
 
已知模型为(x-a)^2+(y-b)^2=r^2,给出十组x,y
,怎么编程求a,b,r:confused:

fanxing39 2007-12-02 21:39

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

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));


所有时间均为北京时间。现在的时间是 13:57

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.