how to find the right distance evaluation function of an ellipse
3 views (last 30 days)
Show older comments
I want to fit a 2D data set to an ellipse using the ransac algorithm . Therefore I use the an equation in polar coordinates, with the origin at the center of the ellipse and with the angular coordinate theta.
ft = fittype( @(a,b,theta,r) (a*b)./sqrt((b*cos(theta)).^2+(a*sin(theta)).^2), 'independent', 'theta', 'dependent','r', 'coefficients', {'a','b'});
fitLineFcn = @(points) fit(points(:,1),points(:,2),ft ) % type function handle
evalLineFcn = ... % distance evaluation function
[modelRANSAC, inlierIdx] = ransac(points,fitLineFcn,evalLineFcn, sampleSize,maxDistance);
How can I compute distances from an ellipse to the data. The example doesnt help me at all.
0 Comments
Answers (1)
Matt J
on 25 Sep 2020
6 Comments
Matt J
on 29 Sep 2020
How can I get your matrix ellipse equation in my fit() ?
Once you have fitted the ellipse, you have the major and minor axes lengths a and b. Assuming you convert your data to a cartesian coordinate system in which the major axis is the x-axis, the A matrix will be given by
A=[1./a.^2, 0;0 1./b.^2];
See Also
Categories
Find more on Linear and Nonlinear Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!