How to find circle from data points

조회 수: 4 (최근 30일)
Jw
Jw 2011년 10월 11일
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

답변 (1개)

Andrei Bobrov
Andrei Bobrov 2011년 10월 11일
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

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by