Path: news.mathworks.com!not-for-mail 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$1@newscl01ah.mathworks.com> References: <jigqp3$f6e$1@newscl01ah.mathworks.com> <jki2uc$ocm$1@newscl01ah.mathworks.com> <jn22c5$bab$1@newscl01ah.mathworks.com> <jn27iu$h0$1@newscl01ah.mathworks.com> <jn28km$459$1@newscl01ah.mathworks.com> <jn4dlf$i0a$1@newscl01ah.mathworks.com> Reply-To: <HIDDEN> NNTP-Posting-Host: www-05-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: newscl01ah.mathworks.com 1335217387 8843 172.30.248.37 (23 Apr 2012 21:43:07 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Mon, 23 Apr 2012 21:43:07 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 1187260 Xref: news.mathworks.com comp.soft-sys.matlab:765652 "M Srj" wrote in message <jn4dlf$i0a$1@newscl01ah.mathworks.com>... > 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