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 Center および File ExchangeMultirate Signal Processing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by