4

I need to fit 10 data points (x,y) into this equation:

ay² + bxy + cx + dy + e = x²

It's told that this is a ellipse-like equation. I can't do it with usual curve fitting tools because it is not really a function (one x corresponds to 2 ys). I can't either use ellipse curve fitting because there is no c*x and d*y in an ellipse equation. Any ideas?

Thanks in advance.

EDIT: Both Oil and AK4749 gave right answer! Thank you guys!

Rody Oldenhuis
  • 37,726
  • 7
  • 50
  • 96
user1532230
  • 157
  • 1
  • 2
  • 7

2 Answers2

6

It is a linear system with variables [a b c d e]. You can use \ to solve it:

 x=rand(10,1);
 y=rand(10,1);
 [y.^2,x.*y,x,y,ones(numel(x),1)]\x.^2

ans =

   -0.4437 %% a
    1.1034 %% b
    0.5337 %% c
   -0.2808 %% d
    0.0402 %% e
Oli
  • 15,935
  • 7
  • 50
  • 66
  • Hi I'm very curious does '\' use least square method in this case? You know, 10 equations with 5 unknowns. – user1532230 Oct 03 '12 at 22:23
  • 1
    @user1532230, yes it does use the min-square method. You can see the documentation there: http://www.mathworks.fr/fr/help/matlab/ref/mldivide.html – Oli Oct 03 '12 at 22:29
0

Give this a shot:

http://www.mathworks.com/matlabcentral/fileexchange/3215-fitellipse

im so confused
  • 2,091
  • 1
  • 16
  • 25