Code covered by the BSD License  

Highlights from
Sphere Fit (least squared)

5.0

5.0 | 5 ratings Rate this file 98 Downloads (last 30 days) File Size: 30.7 KB File ID: #34129
image thumbnail

Sphere Fit (least squared)

by Alan Jennings

 

08 Dec 2011 (Updated 02 Jul 2013)

Fits a sphere to a set of noisy data. Does not require a wide arc or many points.

| Watch this File

File Information
Description

Given a set of data points, this function calculates the center and radius of the data in a least squared sense. The least squared equations are used to reduce the matrix that is inverted to a 3x3, opposed to doing it directly on the data set. Does not require a large arc or many data points. Assumes points are not singular (co-planar) and real...
Created on R2010b, but should work on all versions.

Required Products MATLAB
MATLAB release MATLAB 7.11 (R2010b)
Tags for This File  
Everyone's Tags
fitting curves(3), least squares(2), measurement, noisy data, optimization, sphere(3), statistics
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (10)
30 Jun 2013 Farsat Balata

Dear Alan, could you please, explain more about the two vectors A and B. I don't understand the rationality of Error function you defined as sum((x-xc)^2+(y-yc)^2+(z-zc)^2-r^2)^2,. Is the initial sphere center is taken for partial of the error of each parameter for example xc= mean(x), yc=mean (y) and zc= mean (z) and the function E = sum((xi-mean(x))^2+(y-mean(y))^2+(z-mean(z))^2-r^2)^2 and then, minimze the function E. many thanks

30 Jun 2013 Farsat Balata

Dear Alan, pointing to my previous comment, I have just want to correct the equation
E = sum((xi-mean(x))^2+(yi-mean (y))^2+(zi-mean(z))^2-r^2)^2
Regards

06 May 2013 Farsat Balata

Hi Alan,
Great work I would be happy if you could send me the related paper describing the method.
isxfha@nottingham.ac.uk

04 Apr 2013 JamesAb

Hi Alan. Great code! I really appreciate if you could send me the related paper describing the method:

jamesabott@yahoo.com

Many thanks!

26 Mar 2013 Simao

Hi Alan. Great work! can you please send me the relating papers?

simao.britodaluz@griffithuni.edu.au

much appreciated

11 Mar 2013 Chloe

Hi Alan, any chance you could please send me the relating papers to c.carson@ncl.ac.uk?

Thanks for the code. Works perfect!

22 Jan 2013 Laurens

Works great!

I was wondering if you could send me the paper as well (email: laurens.slot@gmail.com).

Also, how would this look if the radius was known?

19 Dec 2012 luo

Dear Alan, can you send me the related papers? You know, I don't understand the rationality of Error function you defined as sum((x-xc)^2+(y-yc)^2+(z-zc)^2-r^2)^2, since I thought it was supposed to be sum(sqrt((x-xc)^2+(y-yc)^2+(z-zc)^2)-r)^2. My email: lhwsky@mail.ustc.edu.cn. many thanks

27 Aug 2012 Daniel Lopes

Great piece of code!

13 Mar 2012 Tim

works great for my task, and thank you for sending me the related papers! :-)

Updates
02 Jul 2013

Since the matrix A is symmetric, I changed the calculation to avoid superfluous calculations. Runs about 25% faster, and even better for large data sets.

Contact us