From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: fitting curve at polar coordinate
Date: Mon, 23 Apr 2012 21:43:07 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 26
Message-ID: <jn4idb$8kb$>
References: <jigqp3$f6e$> <jki2uc$ocm$> <jn22c5$bab$> <jn27iu$h0$> <jn28km$459$> <jn4dlf$i0a$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1335217387 8843 (23 Apr 2012 21:43:07 GMT)
NNTP-Posting-Date: Mon, 23 Apr 2012 21:43:07 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:765652

"M Srj" wrote in message <jn4dlf$i0a$>...
> Thanks! It is working now and give me parameters a and b. 
> However, the curve fitting is very poor! Actually, my experimental data are like parabola. Do you know better fitting way? 
- - - - - - - - - - -
  It's not surprising that your fit is not good, because you have allowed yourself only two degrees of freedom in the family of functions to fit with R = a/(1+b*cos(theta)).  If you allow the full five parameters of general conics, you could probably get a much better fit.  Here is an approach you might consider.

  Any conic section (including parabolas) can be characterized by the following equation:

  A*x^2 + B*x*y + C*y^2 + D*x + E*y + F = 0

where A, B, C, D, E, and F are appropriate constants.  Let x and y be column vectors of the pairs of cartesian coordinates of the data you wish to fit.  Then do this:

 M = [x.^2,x.*y,y.^2,x,y,ones(size(x))];
 [U,S,V] = svd(M,0);

The sixth (last) column of V will contain the least squares values of [A;B;C;D;E;F] for the above expression subject to the restriction that the sum of their squares is one.  You can test how good the fit is by computing

 A*x.^2 + B*x.*y + C*y.^2 + D*x + E*y + F

to see how near zero it is for your data.

  If your data really is an approximate parabola, you should find that B^2 will be approximately equal to 4*A*C.

  Of course this still leaves you with the problem of how to generate a curve from the above equation, but I'll leave you with that problem for now.

Roger Stafford