matlab - Fitting an ellipse with no tilt on data -



matlab - Fitting an ellipse with no tilt on data -

i'd fit ellipse no tilt on data. equation of ellipse no tilt:

a*x^2 + b*y^2 + c*x + d*y = e

i found solution (http://stackoverflow.com/a/12717181/3179989) interesting, not sure how alter parameters solution problem.

any help appreciated.

edit: here code using:

[y.^2,x,y,ones(numel(x),1)]\x.^2 ans = 1.0e+04 * -0.0000 0.0168 -0.0014 3.6390

this seem work:

%// creating test info x=sin(pi*(2*rand(50,1)-1))+(2*rand(size(x))-1)*.5;x=x./max(abs(x)); y=(sqrt(1-x.^2)+(2*rand(size(x))-1)*.5).*sign(rand(size(x))-0.5)+.5*x; %// setup van der monde matrices , solve equations a=[y.^2,x.*y,x,y,ones(numel(x),1)]\x.^2 b=[y.^2,x,y,ones(numel(x),1)]\x.^2 plot(x,y,'o') %// plot initial info hold on %// plotting results lazy way! [x,y]=meshgrid(1.5*(min([x;y]):.001:max([x;y]))); contour(x,y,-x.^2+a(1)*y.^2+a(2)*x.*y+a(3)*x+a(4)*y+a(5),[0 0],'b') contour(x,y,-x.^2+b(1)*y.^2+b(2)*x+b(3)*y+b(4),[0 0],'k') hold off

the bluish original ellipse , black non-rotated ellipse

matlab curve-fitting ellipse

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -