Quantcast
Channel: MATLAB Central - File Exchange - tag:"least squares"
Viewing all articles
Browse latest Browse all 522

Ellipse Fit

$
0
0
224232008-12-13T11:16:57Z2008-12-13T11:16:57Z

Usage:[semimajor_axis, semiminor_axis, x0, y0, phi] = ellipse_fit(x, y)Input: x - a vector of x measurements y - a vector of y measurementsOutput: semimajor_axis - Magnitude of ellipse longer axis semiminor_axis - Magnitude of ellipse shorter axis x0 - x coordinate of ellipse center y0- y coordinate of ellipse center phi - Angle of rotation in radians with respect to the x-axisAlgorithm used:Given the quadratic form of an ellipse: a*x^2 + 2*b*x*y + c*y^2 + 2*d*x + 2*f*y + g = 0 (1) we need to find the best (in the Least Square sense) parameters a,b,c,d,f,g. To transform this into the usual way in which such estimation problems are presented,divide both sides of equation (1) by a and then move x^2 to the other side. This gives us:2*b'*x*y + c'*y^2 + 2*d'*x + 2*f'*y + g' = -x^2 (2)where the primed parametes are the original ones divided by a. Now the usual estimation technique is used where the problem is presented as:M * p = b, where M = [2*x*y y^2 2*x 2*y ones(size(x))], p = [b c d e f g], and b = -x^2. We seek the vector p, given by: p = pseudoinverse(M) * b.From here on I used formulas (19) - (24) in Wolfram Mathworld:http://mathworld.wolfram.com/Ellipse.html


Viewing all articles
Browse latest Browse all 522

Trending Articles