File Exchange

image thumbnail


version (9.67 KB) by Andrew Horchler
Matlab function for least squares fitting of X-Y data to a circle


Updated 11 Apr 2017

From GitHub

View license on GitHub

Matlab function for least squares fitting of two-dimensional data to a circle.
circfit(X,Y) returns scalar radius R of a fitted circle. X and Y are 1-D arrays of position data in a rectilinear coordinate system. X and Y must be the same length and must contain at least three non-colinear points in order for a valid solution to be found. The function can also return position of the center of the fitted circle and the root mean squared error of the fit.

Additional functions to fit curvature, check colinearity, calculate root mean squared error, and plot the fitted result are included.

Cite As

Andrew Horchler (2021). circfit (, GitHub. Retrieved .

Comments and Ratings (2)

Andrew Horchler

@JeanLuo: How are you using the plotcircfit function? It doesn't return anything so if you try to set it equal to something you'll get that error. See the help in that function for and example of how to use it. Also, that function is mainly a convenience - feel free to take the plotting code from inside the function and modify as you need.

Jean Luo

Hi, when I used the plotcirfit function, I got the error "too many output arguments." Any idea how to fix this?

MATLAB Release Compatibility
Created with R2015b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!