Strange curve fitting with large polynomial degrees when using polyfit
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Star Strider
el 13 de Mayo de 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 comentarios
Ver también
Categorías
Más información sobre Linear and Nonlinear Regression en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!