typestar

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

  1. The fit writes W_coef, and /M=0 keeps the mask out of the way.
  2. V_chisq and W_sigma say how well it went and how sure it is.
  3. /D makes the fit wave so you can plot the result.

Keywords and builtins used here

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.

Type this snippet

Step 1 of 3 in Curve fitting, step 8 of 16 in Waves & analysis.

← Previous Next →