Thomas Dehaeze
6e3677eb29
Folder name is changed, rework the html templates Change the organisation.
15 lines
475 B
Matlab
15 lines
475 B
Matlab
function [c,r] = fitcircle2(x,y)
|
|
% Function to plot a linear least squares circle on a data set
|
|
% x = vector of x-coordinates
|
|
% y = vector of y-coordinates
|
|
% c = center of the circle
|
|
% r = radius of circle (not relevant)
|
|
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));
|
|
c = [xc;yc];
|
|
end |