No BSD License  

Highlights from
CircleFit.m

1.5

1.5 | 2 ratings Rate this file 12 Downloads (last 30 days) File Size: 8.37 KB File ID: #10066
image thumbnail

CircleFit.m

by J. David Cogdell

 

20 Feb 2006 (Updated 21 Feb 2006)

Robust nonlinear least squares fit of exact equation of circle to xy data

| Watch this File

File Information
Description

Iterative, robust fit of the exact equation of a circle to xy data. Outliers are identified based on multiples of current standard deviation and "set aside". The interative solution proceeds until there are no remaining outliers. Returns xo,yo,R, terminal outlier criterion, and residuals vector.

Required Products Optimization Toolbox
MATLAB release MATLAB 7.1.0 (R14SP3)
Other requirements Requires an approximate starting solution for xo,yo,R (e.g. from Datum2D.m)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
21 Feb 2006 John D'Errico

I have not tested this one yet, but there were several things which immediately bothered me from only a quick glance through.
- Nowhere did the help tell me what kind of fit is done. Does it arbitrarily assume the errors lie in y? Does it only handle partial arcs of a circle? Or is it a total least squares solution? The latter makes more sense. It is a circle after all. This should absolutely be repaired, as it should never be necessary for a user to delve into the depths of code to learn facts as important as this.
- Naming the function with internal caps is not my own preference. This causes problems on some operating systems, and its harder to type. Yes, I could change the name, but why?
- A ridiculous choice of help system. In order to get help for this function, the author makes you type "CircleFit help", instead of "help circlefit", which is the standard for every matlab function. Not only is the author's choice non-standard, but it took more work to implement as several dozen displays. Nonstandard help like this is not much different from no help at all.
- There are enough optional arguments and flags to supply here that I'd have leaned towards a property/value pair interface.
- Rather than defaulting to fixed numeric starting values for the parameters, a variety of estimators exist which should yield far better choices, while not forcing the user to supply starting values at all if they would prefer not to.
- The author should try mlint on this code. It made some good suggestions here.
- Finally, the author should reference the prior submission FEX 5557, which appears to do exactly the same thing, except for this code's claim to be a robust fit.
I'll stop here without testing the code itself. Its a start anyway.

21 Feb 2006 Duane Hanselman

By requiring the Optimization Toolbox you limit the usefulness of this function to a small audience. This problem is easily solved using linear least squares which is in basic MATLAB. I agree with John that your help format is ridiculous. How is this function an improvement over FEX 5557? Your help text and use of the Optim. Tlbx are big weaknesses.

22 May 2007 Richard Brown

Note: linear least squares doesn't solve the least squares problem for minimizing distance from the circle to points, which is the "best fit" in the geometric sense. Therefore a nonlinear least squares solution is appropriate.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
optimization J. David Cogdell 22 Oct 2008 08:16:22
robust J. David Cogdell 22 Oct 2008 08:16:22
nonlinear J. David Cogdell 22 Oct 2008 08:16:22
circle J. David Cogdell 22 Oct 2008 08:16:22
circular J. David Cogdell 22 Oct 2008 08:16:22
arc J. David Cogdell 22 Oct 2008 08:16:22

Contact us at files@mathworks.com