Fitting your own function in Igor Pro
FuncFit takes a fit function you wrote, in the shape Igor expects.
Function DoubleExp(WAVE w, Variable t) : FitFunc
return w[0] + w[1] * exp(-t / w[2]) + w[3] * exp(-t / w[4])
End
Function FitDecay(WAVE y)
Make/O/D/N=5 coefs = {0, 1, 0.01, 0.5, 0.1}
FuncFit/Q DoubleExp, coefs, y /D
Printf "fast %.4g s, slow %.4g s\r", coefs[2], coefs[4]
return coefs[2]
End
How it works
- The signature is fixed: a coefficient wave and the independent variable.
- The coefficient wave you pass in holds the initial guess.
FuncFitthen overwrites it with the answer.
Keywords and builtins used here
EndFuncFitFunctionMakePrintfVariableWAVEexpreturn
The run, in numbers
- Lines
- 12
- Characters to type
- 294
- Tokens
- 100
- Three-star pace
- 85 tpm
At the three-star pace of 85 tokens a minute, this run takes about 71 seconds.
Step 3 of 3 in Curve fitting, step 10 of 16 in Waves & analysis.