1. how can I optimize a polynomial with unknown coefficients and unknown order whose x and y values are known?

4 views (last 30 days)
if the polynomial is y=c0+c1x+c2x^2+c3x^3+................. values of x & y are known and how i can get what is the order and unknown coefficients to fit the given grapgh
  1 Comment
Walter Roberson
Walter Roberson on 13 Apr 2014
If the x and y values are known, is there any possibility of "noise" when y was found? Or only of numeric round-off ? Is y found by a physical measurement?

Sign in to comment.

Answers (2)

Star Strider
Star Strider on 13 Apr 2014
I suggest the polyfit function. Links to related functions are at the end of that page.

Image Analyst
Image Analyst on 13 Apr 2014
Edited: Image Analyst on 13 Apr 2014
Like Star Strider said, polyfit() will do it. The order you pick is the number of data points minus 1 (e.g. 2 points use 1 to get a line, 3 points use 2 to get a quadratic, etc.). This will ensure that you have the best possible "fit" because the "fitted" curve will go exactly through each and every data point. Of course in between data points and to the left of the left one and to the right of the rightmost one, you'll have huge wild and crazy values.
Please define EXACTLY what "those data are not fit to my given curve" means by showing a screenshot of what you did .
  2 Comments
smitirupa
smitirupa on 14 Apr 2014
The order you pick is the number of data points minus 1 (e.g. 2 points use 1 to get a line, 3 points use 2 to get a quadratic, etc.. I am not getting this. In my case 110 data points are there for the value of x & y.I want to draw exact curve of that given one. I am attaching the given data. I already gave the polynomial with unknown order and unknown coefficients. Please go through that and give detailed procedure as i m new user.
Walter Roberson
Walter Roberson on 14 Apr 2014
If you have exact measurements for N positions and N corresponding datapoints, and if you have indefinite precision calculations, then you can construct a polygon of order (N-1) that will fit all of the points perfectly.
In some cases you might also be able to find an exact fit of lower order. Is that the situation for you, that you suspect that there might be some redundant points?
Note that if your data is a finite truncation of infinite values, or if you have any round-off error in the calculation that generated the y, or if even the slightest bit of noise, then finding the redundant points can be spoiled. And if you do not use indefinite precision arithmetic in doing to operations upon the coefficients that you find, then you might end up with a very large error between the predicted values and the actual values.
As a "rule of thumb", by the time you get to order 8 polynomials (9 points) then round off in finite arithmetic will result in inexcusable errors in doing projections. Lower orders will have notable errors as well. Some people say that if you are fitting at higher than order 4 then you are probably making a mistake if you are relying on double precision.

Sign in to comment.

Tags

No tags entered yet.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!