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

2 次查看(过去 30 天)
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

回答(2 个)

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

Image Analyst
Image Analyst 2014-4-13
编辑:Image Analyst 2014-4-13
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 个评论
smitirupa
smitirupa 2014-4-14
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 2014-4-14
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Least Squares 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by