File Exchange

image thumbnail

Circle Fit (Pratt method)

version (2.18 KB) by Nikolai Chernov
Fits a circle to a set of data points on a plane; returns the circle center (a,b) and radius R.


Updated 10 Jan 2009

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

This is a robust and accurate circle fit. It works well even if data
points are observed only within a small arc. This circle fit was proposed by V. Pratt in article "Direct least-squares fitting of algebraic surfaces", Computer Graphics, Vol. 21, pages 145-152 (1987). It is more stable than the simple Circle Fit by Kasa (file #5557).

Cite As

Nikolai Chernov (2020). Circle Fit (Pratt method) (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (23)


Nice work! How can I modify this code to give me circle center if I already know circle radius?

Taylor Wang

Nice one. Easy to understand and use


Congli Sun

The definition of inputs and outputs are clear enough. It is also very practical. Thank you.

I keep getting an error Newton-Pratt negative root: x=-0.000000 and Newton-Pratt will not converge. What do these mean and how do I fix it?

Anam Farooq

what is XY in code? .. declare undefined fucntion or variable . how to declare?
. plz guide me ?how to solve it?

Chow Alex

Great work thanks very much

hing ho

hello, are you have excel vba version? thank a lot!

Qiliang Lin

very helpful. Thanks!


It works perfectly and helps me so much,thank you.


can anyone please tell me how to give inputs to circle fit by pratt method.


i need to fit a circle to find the curvature of a line at various points using the radius. can u suggest a way to check my results. Thank u in advance.

Gwen Bailey

Thank you very much for this algorithm. I was looking for an algorithm to fit a small number of data points (around 50) to a small portion of a circle (less than 10 degrees of the outline) and found this one to work perfectly. I had previously been using the Bucher circle fit and found it to be nowhere near as accurate or stable (although it is faster).

Thanks again!

Gwen Bailey

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

Inspired by: Circle fit