curve fit triple exp w/ X offset

Hi,

I'm trying to build a triple exp with X offset curve fit function. I would like it to work exactly the same as the build-in dblexp_XOffset function with a set constant of x0 auto, x data using _calculated_, and auto initial guess for coefs. I've had no luck in determining how to build in any of the above aspects. Below is what I have written. Any help would be greatly appreciated.

Thanks,
Gerry

Function triplexp_xoffset(w,x,xo) : FitFunc
Wave w
Variable x
Variable xo

//CurveFitDialog/ These comments were created by the Curve Fitting dialog. Altering them will
//CurveFitDialog/ make the function less convenient to work with in the Curve Fitting dialog.
//CurveFitDialog/ Equation:
//CurveFitDialog/ f(x,xo) = yo + (A1 * (exp((x-xo)/t1))) + (A2 *(exp((x-xo)/t2))) + (A3 * (exp((x-xo)/t3)))
//CurveFitDialog/ End of Equation
//CurveFitDialog/ Independent Variables 2
//CurveFitDialog/ x
//CurveFitDialog/ xo
//CurveFitDialog/ Coefficients 7
//CurveFitDialog/ w[0] = yo
//CurveFitDialog/ w[1] = A1
//CurveFitDialog/ w[2] = t1
//CurveFitDialog/ w[3] = A2
//CurveFitDialog/ w[4] = t2
//CurveFitDialog/ w[5] = A3
//CurveFitDialog/ w[6] = t3

return w[0] + (w[1] * (exp((x-xo)/w[2]))) + (w[3] *(exp((x-xo)/w[4]))) + (w[5] * (exp((x-xo)/w[6])))
End

Gerry-

I will be hard to duplicate the features of the built-in fits. The constants are tough to incorporate into user-defined fitting functions.

The easiest approach is to make x0 another fit coefficient. Then you have to give it a value and hold it when you fit a given data set.

A harder approach is to use a structure fit function. It was designed with these sorts of things in mind. The drawbacks are:

1) you can't use then from the Curve Fit dialog (you can't even create them there, but you can modify what you already have).

2) you can't use them on the command line- you have to call them from a function, because Igor structures only live inside functions.

Point 2 means that you have to wrap a call to FuncFit in a function that creates the structure used by your fit function. To read more about structure fit functions (and all other styles of user-defined fit functions) execute this command on Igor's command line:

DisplayHelpTopic "User-Defined Fitting Function: Detailed Description"

The description of structure fit functions is down a ways, but it's probably a good idea to read the whole section. The example in the documentation is a single exponential fit with x offset constant.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com