Generate a mathematical funciton from a graph or raw data?

10 visualizaciones (últimos 30 días)
Ronan
Ronan el 19 de Nov. de 2015
Comentada: John D'Errico el 19 de Nov. de 2015
I m used to using mathematical functions however if I want to describe raw data as a mathematical function I m not really sure where to begin. So, for example I know data is linear if y = x and I know its cubic if y = x^3 but is it possible for matlab to use a general function to detect what kind of mathematical function the raw data describes? And based on the description of the funcions described I want to be able to dynamically detect this and change the behaviour of the program based on this.

Respuestas (1)

the cyclist
the cyclist el 19 de Nov. de 2015
I appreciate that this seems like a thing that one would want to do. But it is not. Here is a small part of the reason why.
Suppose that you have N = 2 data points. Easy enough! Fit a line. Perfect fit. Done.
Now suppose you have N = 3 data points. Still pretty easy! Fit a parabola (i.e. a 2nd order polynomial). Perfect fit again. I'm so good at this!
N = 4 points ... Fit a cubic, the 3rd-order polynomial. Perfect fit. Wow! (Do you see where I am going with this?)
Arbitrary N points ... Fit an (N-1)th order polynomial. Perfect fit!
The trouble, as I hope you might realize, is that that perfect-fitting polynomial probably has little or no relationship to the underlying process that generated those data, because it is fitting the noise as well as the signal. It is "overfitting".
And, notice, I have only used polynomial fitting here. There are zillions of other functional forms that could also have given perfect fits.
It's a fool's errand to try what you suggest.
For less foolish approaches, I strongly suggest Learning from Data.
  3 comentarios
Stephen23
Stephen23 el 19 de Nov. de 2015
Editada: Stephen23 el 19 de Nov. de 2015
What the cyclist states is perfectly correct, but there is also the special case of where you have some prior knowledge of the system, and can therefore limit the system to some known set of functions. This might work if you have measurements of a simple physical phenomenon, for example. In practice this would mean non-linear curve fitting, a fit metric and some selection criteria.
John D'Errico
John D'Errico el 19 de Nov. de 2015
The problem is, in order to use a nonlinear model, you need to have some model in mind. There is no intelligent, automatic way to just pick the overall nonlinear form that would represent your data. Ok, there are computer programs that will fit every model from a complete stable of models, then pick the one with the "best" fit. I have no good feeling towards those schemes. Sorry, but no.
If you have no intelligent choice of model, then it is very often better to use a spline model, such as my SLM toolbox . It allows you to build in your own knowledge about the process into the model, like if it should be a monotonic function.

Iniciar sesión para comentar.

Categorías

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