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
댓글 수: 1
Walter Roberson
2014년 4월 13일
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?
답변 (2개)
Star Strider
2014년 4월 13일
댓글 수: 2
Star Strider
2014년 4월 13일
편집: Star Strider
2014년 4월 13일
Upload your (x,y) data as an attachment to your original question.
What process generated your data?
What else have you tried?
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
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 Center 및 File Exchange에서 Least Squares에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!