Fitting a built-in shape in Igor Pro
CurveFit carries a library of shapes; the coefficients come back in W_coef.
Function FitPeak(WAVE y, WAVE x)
CurveFit/Q/M=0 gauss, y /X=x /D
WAVE W_coef, W_sigma
Printf "center %.4g +/- %.4g\r", W_coef[2], W_sigma[2]
Printf "width %.4g\r", W_coef[3]
Printf "chi squared %g\r", V_chisq
return W_coef[2]
End
How it works
- The fit writes
W_coef, and/M=0keeps the mask out of the way. V_chisqandW_sigmasay how well it went and how sure it is./Dmakes the fit wave so you can plot the result.
Keywords and builtins used here
CurveFitEndFunctionPrintfWAVEgaussreturn
The run, in numbers
- Lines
- 10
- Characters to type
- 232
- Tokens
- 54
- Three-star pace
- 85 tpm
At the three-star pace of 85 tokens a minute, this run takes about 38 seconds.
Step 1 of 3 in Curve fitting, step 8 of 16 in Waves & analysis.