'Polyfit' vs 'Detrend' function

18 visualizaciones (últimos 30 días)
Ashfaq Ahmed
Ashfaq Ahmed el 7 de Ag. de 2023
Respondida: Star Strider el 7 de Ag. de 2023
Hi al, I have a quick question regarding how does the 'Detrend' function work. Is it a linear regression method? And If we want to detrend a data set, will they both give us the same result?

Respuesta aceptada

Star Strider
Star Strider el 7 de Ag. de 2023
It can be linear although polynomial trends are permitted. To visually understand how it works, see the documentation section on Continuous Linear Trend.
If you apply the polyfit result the same way as detrend does, they will likely give the same result. The advantage to detrend is that it does all that with one call, specifying the dependent variable and the polynomial degree being the only requirements. (It also has additional options.)
(I generally use polyfit and polyval to detrend a baseline, using polyfit to fit the polynomial to the results of calling the islocalmin function with the dependent variable, and then using polyval with that polynomial on the entire independent variable vector to get the detrending vector.)

Más respuestas (0)

Categorías

Más información sobre Polynomials 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!

Translated by