Curve Fitting and extrapolation for a semi-circle

11 views (last 30 days)
Hello,
I have a set of data that (almost) makes a quadrant of a circle. I would like to do curve fitting (I only know polyfit so far in detail) on this dataset and then proceed to complete a semicircle along these datapoints, so the fitted curve would touch the x-axis.
My goal is to find the value at which this fitted curve (semicircle) intersects the x-axis.
Can someone explain to me in detail how I may achieve this?

Answers (1)

John D'Errico
John D'Errico on 3 Feb 2022
Edited: John D'Errico on 3 Feb 2022
There are many circle fitting tools to be found on the file exchange. You can use and download one of them, but I will concede that many of those posted are of questionable quality. Since I also wrote a circle fitting tool, I might as well attach it here. The nice thing about my circlefit code is it tries to be as intelligent as possible about the process. It uses a specialized least squares regression code to solve for the best fit circle. In really bad cases, it can even be set to use robustfit from the stats toolbox, if you have that toolbox.
xy = [ 0.31523 0.90108
0.97953 0.15193
0.89117 0.47983
0.55205 0.83453
0.238 0.98173
0.51019 0.77948];
plot(xy(:,1),xy(:,2),'go'),grid on,axis equal,axis square
The use of circlefit is easy.
[C,R,rmse] = circlefit(xy)
C = 1×2
-0.0960 -0.1071
R = 1.1170
rmse = 0.0286
So the center of the circle as found is [-0.09690, -0.11071], and the radius is 1.1170. I chose points only in the first quadrant, so you can see it can be used on a portion of a circle.
Finally, since a circle has a simple equation, we know it intersects the x axis. Where is that point of intersection? simple paper and pencil suffice. The two points of intersection with the x axis happen when y==0, so we would have:
C(1) - sqrt(R^2 - C(2)^2)
C(1) + sqrt(R^2 - C(2)^2)
We want the intersection point on the right in this case, so will be the second of the two I have listed.
theta = linspace(0,pi/2);
xc = C(1) + R*cos(theta); yc = C(2) + R*sin(theta);
hold on
plot(xc,yc,'r-')
xintersection = C(1) + sqrt(R^2 - C(2)^2)
xintersection = 1.0158
plot(xintersection,0,'bx')

Community Treasure Hunt

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

Start Hunting!