To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016
I am trying to fit a second order exponential to a standard set of experimental mechanical creep data. See below.
[creep_data_fit, gof] = fit(time , distance, 'exp2');
I have data that goes out to 3 hours but when I plot and fit data less than that the fit deviates towards infinity (theoretical fit for creep data) instead of to a steady state (experimental fit for creep data). The format of the fit is below.
Y = a*exp(b*x)+c*exp(d*x)
The function is fitting positive coefficients for a and b and negative coefficients for c and d. However, if the fit used negative coefficients for a, b, c, and d it would more closely approximate my experimental data.
Is there a way to give a negative range of proposed values for the coefficients?
Or is there a better way to "force" the fit to my data?
No products are associated with this question.
Type "help fit" and you'll see the fourth input can be a fitoptions structure. Then type "help fitoptions" and you'll see you can create one doing something like this, specifying lower and upper bounds for four coefficients:
fo = fitoptions('exp2','lower',[1 2 3 4],'upper',[2 4 6 8])
Maybe Matt's idea is better, but this shows how to use "fit" to do it.
LSQCURVEFIT, if you have it, let's you impose bound constraints. However, you would probably want to re-parametrize the curve something like the following, so that the two exponential terms can be distinguished.
Y = a*exp(b*x)+c*exp((b+d^2)*x)
This ensures that the second exponential term always has a slower decay than the first term. Even better would be
Y = a*exp(b*x)+c*exp((b+d^2+q)*x)
if you know some minimum amount q>0 by which the decay rates should differ