I'd like to force my exponential fit to start at [0 0]

So, I've got some noisy data. When averaged, the data fit nicely along a double exponential fit, starting off with with a positive slope that decays to near 0 (horizontal line).
However, when I want to fit the same curve to the individual traces, things aren't so neat. Sometimes, the slope is initially negative and shallows out, other times, it's flat and then increases exponentially at the end.
Some of them look great, like this: http://i35.tinypic.com/23si5bs.jpg
And some of them fit poorly, like this: http://i34.tinypic.com/2rfdaxe.jpg
How can I force the exponential fit that I want? It seems like 'Startpoint' is a good starting point (heh).
Here's my code:
[u,gof] = fit(time,y,'exp2');
And this doesn't seem to work:
[u,gof] = fit(time,y,'exp2','Startpoint',[0 0]);
??? Index exceeds matrix dimensions.
Any thoughts would be appreciated.
Thanks, Stefan

Respuestas (1)

Joe S
Joe S el 24 de Abr. de 2013

0 votos

Not sure if it will fix it, but remember an exponential function can never equal zero unless your A1 & A2 are both 0 (which you don't want). Try a small positive number, say 0.001 for your y-start..

3 comentarios

Stefan
Stefan el 24 de Abr. de 2013
Hi Joseph, Thanks for your response. Do you mean add a data point that's near [0,0], or to put the startpoint at 0.001?
If the latter, I don't actually know how to implement start points. You can see that my code returns a matrix error, which I'm sure is a syntax problem of some sort.
For any exponential function, f(x+1)/f(x) is always a constant (dependent on the exponential being used.) If any f(x+1) was exactly 0 for finite x, then f(x) would have to have been 0 as well, and by induction f(x) would have to be identical to 0. Therefore no exponential function can ever be exactly 0 at any finite location.
You can force an exponential to fit exactly through any finite non-zero location, but not through 0.
Stefan
Stefan el 24 de Abr. de 2013
Ok. I haven't been able to implement a start point at all for using 'fit,' and there aren't examples of its use outside of the cftool.
Do you know of any good examples of using code to restrain the startpoints?

Iniciar sesión para comentar.

Categorías

Más información sobre Get Started with Curve Fitting Toolbox en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 24 de Abr. de 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by