Strange curve fitting with large polynomial degrees when using polyfit
조회 수: 3 (최근 30일)
이전 댓글 표시
I'm trying to fit a curve to my points by using polyfit, I'm getting normal results for small polynomial degrees, but when i want to use polyfit for bigger polynomial degrees, I get strange results.
This is what I get when for degree of 10:
It's okay and its normal, but when I use polyfit for the degree of 100, I get strange results for the starting points and the ending points:
What's the reason for this strange behavior? How can i fix this?
댓글 수: 0
답변 (1개)
Star Strider
2021년 5월 13일
As a general rule, a polynomial fit with a degree grater than 7 is likely not appropriate, so a 100 degree polynomial is giving the expected result, with ‘ringing’ at the extremes.
It would appear that fitting a sine curve to the data would be appropriate. One approach to that is described in Curve fitting to a sinusoidal function. The one change I would make in that code is to replace the ‘zci’ fundtion with this one:
zci = @(x) find(diff(sign(x)));
It is more robust, and does not have the ‘end effect’ my original function does.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Interpolation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!