Strange curve fitting with large polynomial degrees when using polyfit
2 次查看(过去 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!