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.
I'm glad this is useful for you. If you notice, there's a symmetry that you can extend to N dimensions. If you're very savy, you can do it progamatically without a for loop; but I thought that would make the code harder to understand. The derivation also extends to N dimensions, so the answer will still be the least square error (of the squared distance).
thanks for this great function! Is there any chance for me to get the related papers explaining this method, as well? Tried to research it the whole day - without succes...
Thanks a lot!
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
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: firstname.lastname@example.org. many thanks