nlfFit
Description
Get the value of the specified dependent variable for the specified value of the independent variable.
Syntax
double nlfFit( double dx, int nDepend = 0 )
Parameters
- dx
- [input] value of the independent variable
- nDepend
- [input] dependent variable ( 0 based offset)
Return
Returns the value of the specified dependent variable for the given value of the independent variable.
Examples
EX1
bool LTNLSF_fit(curvebase& crvData, vector& fitx, vector& fity, int i1, int i2, LPCSTR lpcszFunc)
{
int nMissing, nSrcOffset;
Curve cvcpy(crvData, nMissing, nSrcOffset, CURVECOPY_SKIP_MISSING_INSIDE, i1, i2);
using NLSF = LabTalk.NLSF;
NLSF.Init(); // initialize fitter
NLSF.Func$ = lpcszFunc;
NLSF.Output(0);
NLSF.FitData$ = cvcpy.GetName();
NLSF.Execute("parainit"); // perform auto parameter initialization
NLSF.Iterate(100);
NLSF.End(13);
Dataset cvcpyx;
cvcpy.AttachX(cvcpyx);
fitx = cvcpyx;
fity = nlfFit(fitx); // get fit Y values given X values, using Origin C vector mechanism with functions with double argument
return true;
}
void test(int i1 = 0, int i2 = -1, string strFunc = "Gauss", string strRwks = "FitCurve")
{
Worksheet wksData = Project.ActiveLayer();
Curve crvData(wksData, 0, 1);
if(!crvData)
return;
vector vx, vy;
LTNLSF_fit(crvData, vx, vy, i1, i2, strFunc);
Worksheet wksResult(strRwks);
if(!wksResult)
{
wksResult.Create();
wksResult.GetPage().Rename(strRwks);
}
Dataset fitdx(wksResult, 0);
Dataset fitdy(wksResult, 1);
fitdx = vx;
fitdy = vy;
}
Remark
Get the value of the specified dependent variable for the specified value of the independent variable. This function is used in conjunction with the internal Origin Non-linear Least Squares Fitter (NLSF) object and uses the most recent fitting function and parameter values specified through the NLSF interface or through script.
See Also
header to Include
origin.h
Reference
|