Sometimes, you may wish to fit a reference wave to a source wave solely by scaling (multiplying by a factor) and offsetting. Here is an example of the fitting functions needed to accomplish this task. The operations rely on duplicating the reference wave as a global. The fit_ref2src function should only be called through the do_fitref2src function or an equivalent. The function leaves wcoeff containing the scaling and offset.
Function do_fitref2src(wave source, wave reference)
make/N=2/O/D wcoeff = {1,0}
duplicate/O reference greference
FuncFit/Q fit_ref2src, wcoeff, source
killwaves/Z greference
return 0
end
Function fit_ref2src(wave wc, variable xx) : FitFunc
wave greference
return (wc[0]*greference(xx) + wc[1])
end
While simple, I post it for the benefit both of the newcomers to Igor Pro as well as the somewhat seasoned folks such as me who tend to forget such simple things exactly when they are needed.