Strange curve fitting with large polynomial degrees when using polyfit
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Star Strider
il 13 Mag 2021
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 Commenti
Vedere anche
Categorie
Scopri di più su Linear and Nonlinear Regression in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!