How to find circle from data points
2 views (last 30 days)
Show older comments
How do i detect circle,circle center and radius from my data points?
clear all;clc;
x=zeros(1,361);
y=zeros(1,361);
x=[-90:0.5:90];
for i=1:361
if (1<=i && i<160)
y(i)=0.2*x(i)+3;
end
if (161<=i && i<200)
y(i)=-sqrt(10^2-(x(i)^2));
end
if (201<=i && i<361)
y(i)=-0.2*x(i)+3;
end
end
figure
plot(x,y,'b.')
axis equal
0 Comments
Answers (1)
Andrei Bobrov
on 11 Oct 2011
dy = diff(y,2);
idx = find(abs(dy) > 1e-10)+1;
idc = idx(5)+(0:2:4);
id = [x(idc)',y(idc)'];
f = @(x,y)(y(:,1)+x(1)).^2+(y(:,2)+x(2)).^2 - x(3).^2;
xabr = fsolve(@(x)f(x,id),[0 0 1]').*[-1; -1; 1];
xabr(1:2) % coordinate of center circle [x;y]
x(3) % radius circle
0 Comments
See Also
Categories
Find more on Multirate Signal Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!