필터 지우기
필터 지우기

How can I plot a circle use given point?

조회 수: 4 (최근 30일)
Seong-Won Ham
Seong-Won Ham 2021년 1월 25일
댓글: weikang zhao 2021년 1월 25일
I want to plot a circle, use given data.
but, I just know the some of the point in circle, but do not midpoint and radius.
Then, How Can I plot the circle using a given point?

답변 (2개)

KSSV
KSSV 2021년 1월 25일
If you have points.....you can find the radius of circle. It depends on how many points you know.
Frame the distance formula and solve the equations.

weikang zhao
weikang zhao 2021년 1월 25일
If you have coordinates of three points, the radius and center of the circle can be obtained by solving a positive definite equation set. If you have more points, there will be a overdetermined set, the midpoint and radius have a least squares estimation.
  댓글 수: 2
Seong-Won Ham
Seong-Won Ham 2021년 1월 25일
Thanks for your ccomments.
Now, I have a lot of point data and will try least squares estimation to find the equation.
I wonder that the best code of calculate radius.
If you have an idea of code, Please comment for me.
I'm sorry that my poor english.
thanks.
weikang zhao
weikang zhao 2021년 1월 25일
give you a demo:
clear
c=[5;5];%real coordinate of midpoint
r=3;%real radius
pointNum=20;%num of all the points
thetatrain=unifrnd(0,2*pi,1,pointNum);
rtrain=r+0.01*randn(1,pointNum);
xytrain=c+[rtrain.*cos(thetatrain);rtrain.*sin(thetatrain)];%Generate a set of points perturbed around the circle
plot(xytrain(1,:),xytrain(2,:),'.');
A=[xytrain.',ones(pointNum,1)];
b=sum(xytrain.^2).';
est=(A.'*A)\A.'*b;
rhat=sqrt(est(1)^2/4+est(2)^2/4+est(3));%LS estimate of radius
xhat=est(1)/2;%LS estimate of the x coordinate of midpoint
yhat=est(2)/2;%LS estimate of the y coordinate of midpoint
hold on;
plot(xhat+rhat*cos(0:pi/180:2*pi),yhat+rhat*sin(0:pi/180:2*pi));
If you are interested in mathematical principles, email me. my email address

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by