Asked by Alison
on 17 Apr 2013

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.*

Answer by Tom Lane
on 18 Apr 2013

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.

Alison
on 18 Apr 2013

Great thank you I tried both of these and they worked well!

Harold Bell
on 18 Oct 2013

Could you please comment on how to decide good upper and lower bounds? Everyone says "according to your data." But how to actually decide? Isn't it cheating in a way if you make it too narrow?

Matt J
on 18 Oct 2013

**Isn't it cheating in a way if you make it too narrow?**

I wouldn't say it's cheating. It just might lead to a very poor fit.

The choice of the bounds should be derived from modeling insights, i.e., from prior information you have about the process that generated the data. If your prior information doesn't give a clue to that, then maybe you shouldn't use bounds.

Answer by Matt J
on 17 Apr 2013

Edited by Matt J
on 17 Apr 2013

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

Alison
on 18 Apr 2013

Great thank you I tried both of these and they worked well!

Related Content

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today
## 0 Comments