Matlab: how to fit time series with a funcion of a certain type

74 views Asked by At

I'm having a time series and need to aproximate it with some function which is easy to calculate. It looks like the row is something like

(a*x*x + b*x + c) / (d*x + e)

Is there a way to find the coeficients automatically (with Matlab or whatever) the so that the obtained function fit series the best?

Thank you in advance!

1

There are 1 answers

0
Ed Smith On BEST ANSWER

The easiest way with Matlab (if you have the curve fit toolbox) is to use the cftool. This gives you a gui which you can import the data and play with the best fit.

If you need to build this into a code then you can use the best function found from cftool using fit from the curvefit toolbox. You can define the custom function fit with something like

f = @(a, b, c, d, e, x) (a*x.*x + b*x + c) / (d*x + e)
fit(x, y, f, 'StartPoint', [0.,0.,0.,0.,0], 'Robust', 'LAR')