User defined equation does not show up in batch curve fitting window
TRK
I need to do batch curve fitting on the 2D wave. I went through the example experiment, the procedure file in it, and also the forum post. Based on these, I tried writing two codes on the procedure file that would fit my data points; however the user defined equation does not appear on the batch curve fit window. I would appreciate any suggestion or comments on this. Here is my code.
#pragma rtGlobals=3 // Use modern global access method and strict wave access.
#include <WMBatchCurveFitIM>
Function FitMySpectrum(ww, xx) : FitFunc //code for the fitting of spectrum
WAVE ww
Variable xx
Variable w1=0, w2=0, w3=0, w4=0, w5=0, w6=0, qq=0
Variable T1=0.23, S1=0.064, T2=0.09, S2=0.12, x1=1.92, x2=2.17
// local variable
//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/ qq(xx) = (A1*(exp(0.5*(S1/T1)^2-(xx-x1)/T1))*erfc(0.707*(S1/T1-(xx-x1)/S1)))+(A2*exp(0.5*(S1/T1)^2-(xx-x2)/T2)*erfc(0.707*(S2/T2)-(xx-x2)/S2))
//CurveFitDialog/ End of Equation
//CurveFitDialog/ Independent Variables 1
//CurveFitDialog/ xx
//CurveFitDialog/ S1 --> Set equal to 0.064
//CurveFitDialog/ T1 --> Set equal to 0.23
//CurveFitDialog/ S2 --> Set equal to 0.12
//CurveFitDialog/ T2 --> Set equal to 0.09
//CurveFitDialog/ x1 --> Set equal to 1.92
//CurveFitDialog/ x2 --> Set equal to 2.17
//CurveFitDialog/ Coefficients 2
//CurveFitDialog/ ww[0] = A1
//CurveFitDialog/ ww[1] = A2
return (ww[0]*(exp(0.5*(S1/T1)^2-(xx-x1)/T1))*erfc(0.707*(S1/T1-(xx-x1)/S1)))+(ww[1]*exp(0.5*(S1/T1)^2-(xx-x2)/T2)*erfc(0.707*(S2/T2)-(xx-x2)/S2))
End
//Second code
<pre><code class="language-igor">
Function FitMySpectrum(ww, xx) : FitFunc //code for the fitting of spectrum
WAVE ww
Variable xx
Variable w1=0, w2=0, w3=0, w4=0, w5=0, w6=0, qq=0
Variable T1=0.23, S1=0.064, T2=0.09, S2=0.12, x1=1.92, x2=2.17
//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/ qq(xx) = (A1*(exp(0.5*(S1/T1)^2-(xx-x1)/T1))*erfc(0.707*(S1/T1-(xx-x1)/S1)))+(A2*exp(0.5*(S1/T1)^2-(xx-x2)/T2)*erfc(0.707*(S2/T2)-(xx-x2)/S2))
//CurveFitDialog/ End of Equation
//CurveFitDialog/ Independent Variables 1
//CurveFitDialog/ xx
//CurveFitDialog/ S1
//CurveFitDialog/ T1
//CurveFitDialog/ S2
//CurveFitDialog/ T2
//CurveFitDialog/ x1
//CurveFitDialog/ x2
//CurveFitDialog/ Coefficients 2
//CurveFitDialog/ ww[0] = A1
//CurveFitDialog/ ww[1] = A2
// Body code
w1 = exp(0.5*(S1/T1)^2-(xx-x1)/T1)
w2 = erfc(0.707*(S1/T1-(xx-x1)/S1))
w3 = ww[0]
w4 = exp(0.5*(S2/T2)^2-(xx-x2)/T2)
w5 = erfc(0.707*(S2/T2-(xx-x2)/S2))
w6 = ww[1]
qq = w3*(w1*w2)+w6*(w4*w5)
return qq
End
#include <WMBatchCurveFitIM>
Function FitMySpectrum(ww, xx) : FitFunc //code for the fitting of spectrum
WAVE ww
Variable xx
Variable w1=0, w2=0, w3=0, w4=0, w5=0, w6=0, qq=0
Variable T1=0.23, S1=0.064, T2=0.09, S2=0.12, x1=1.92, x2=2.17
// local variable
//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/ qq(xx) = (A1*(exp(0.5*(S1/T1)^2-(xx-x1)/T1))*erfc(0.707*(S1/T1-(xx-x1)/S1)))+(A2*exp(0.5*(S1/T1)^2-(xx-x2)/T2)*erfc(0.707*(S2/T2)-(xx-x2)/S2))
//CurveFitDialog/ End of Equation
//CurveFitDialog/ Independent Variables 1
//CurveFitDialog/ xx
//CurveFitDialog/ S1 --> Set equal to 0.064
//CurveFitDialog/ T1 --> Set equal to 0.23
//CurveFitDialog/ S2 --> Set equal to 0.12
//CurveFitDialog/ T2 --> Set equal to 0.09
//CurveFitDialog/ x1 --> Set equal to 1.92
//CurveFitDialog/ x2 --> Set equal to 2.17
//CurveFitDialog/ Coefficients 2
//CurveFitDialog/ ww[0] = A1
//CurveFitDialog/ ww[1] = A2
return (ww[0]*(exp(0.5*(S1/T1)^2-(xx-x1)/T1))*erfc(0.707*(S1/T1-(xx-x1)/S1)))+(ww[1]*exp(0.5*(S1/T1)^2-(xx-x2)/T2)*erfc(0.707*(S2/T2)-(xx-x2)/S2))
End
//Second code
<pre><code class="language-igor">
Function FitMySpectrum(ww, xx) : FitFunc //code for the fitting of spectrum
WAVE ww
Variable xx
Variable w1=0, w2=0, w3=0, w4=0, w5=0, w6=0, qq=0
Variable T1=0.23, S1=0.064, T2=0.09, S2=0.12, x1=1.92, x2=2.17
//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/ qq(xx) = (A1*(exp(0.5*(S1/T1)^2-(xx-x1)/T1))*erfc(0.707*(S1/T1-(xx-x1)/S1)))+(A2*exp(0.5*(S1/T1)^2-(xx-x2)/T2)*erfc(0.707*(S2/T2)-(xx-x2)/S2))
//CurveFitDialog/ End of Equation
//CurveFitDialog/ Independent Variables 1
//CurveFitDialog/ xx
//CurveFitDialog/ S1
//CurveFitDialog/ T1
//CurveFitDialog/ S2
//CurveFitDialog/ T2
//CurveFitDialog/ x1
//CurveFitDialog/ x2
//CurveFitDialog/ Coefficients 2
//CurveFitDialog/ ww[0] = A1
//CurveFitDialog/ ww[1] = A2
// Body code
w1 = exp(0.5*(S1/T1)^2-(xx-x1)/T1)
w2 = erfc(0.707*(S1/T1-(xx-x1)/S1))
w3 = ww[0]
w4 = exp(0.5*(S2/T2)^2-(xx-x2)/T2)
w5 = erfc(0.707*(S2/T2-(xx-x2)/S2))
w6 = ww[1]
qq = w3*(w1*w2)+w6*(w4*w5)
return qq
End
I examine the procedure file for batch curve fitting and find that it may be due to the following code:
in
December 3, 2017 at 03:24 am - Permalink
Thank you Wings. It works well after clearing the comments
December 3, 2017 at 06:52 am - Permalink