Max value of a fit
Mostrar comentarios más antiguos
How do I find the max value of a fit to data. I am using:
f=fit(x,y,'poly5')
I have tried
p=polyder(f)
roots(P)
But I get an error
Respuesta aceptada
Más respuestas (1)
John D'Errico
el 19 de Mzo. de 2015
Editada: John D'Errico
el 19 de Mzo. de 2015
So what error did you get? It helps if you are complete in your comments about an error so that others can help you.
I'll bet that since polyder is not designed to work with polynomials in the form that polyfit generates, that it did not understand how to work with the polynomial object returned from fit.
This should work though:
roots(polyder(coeffvalues(f)))
1 comentario
John D'Errico
el 19 de Mzo. de 2015
To determine the maximum value, you evaluate the function at each (real) candidate. Thus at each root of the derivative, evaluate the original function, and take the maximum value over all candidate roots.
If a root was outside of the interval (the support of your data) then this would be extrapolation, so generally a bad idea to use extrapolated values for this, especially if the extrapolation was done from a polynomial.
In some circumstances, you might also compare the value of the function at the first and last data point, assuming you choose not to allow extrapolation. For the curve as shown in your figure, this is of course not necessary.
Categorías
Más información sobre Descriptive Statistics and Insights en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
