# 3.7.5.44 NLSF

LabTalk Object Type:

External Object
 This object is obsolete. Use the nlbegin, nlfit, nlend and related X-Functions.

The NLSF object performs nonlinear least squares fitting. Curve fitting from script can be controlled through the this object's methods and properties.

## Properties:

Property Access Description
numeric

This is a vector value that stores values of the confidence interval for each parameter (Confidence Interval = Parameter Error * Chi-square Value). All the elements of this vector are shown in the ConfInter column of the Parameter worksheet.

numeric

Read the reduced chi-square value. This value is computed during iterations.

numeric

Set the status of the Scale Errors with sqrt(reduced chi-square) check box on the Control Parameters dialog box. 0 = clear the check box. 1 = select the check box. For more information on this check box, see the Origin Help file.

numeric

Read the coefficient of determination (r^2 value). The COD value is computed at the end of a round of fitting iterations. For the mathematical definitions of COD, see the Origin Help file.

numeric

Report/control the state of the Compile Before Use check box located on the New Function / Edit Function tab of the NLSF: 0 = unchecked (do not compile), 1 = checked (compile) The current function is set from nlsf.func$. nlsf.conf Read/write numeric Set the confidence level value. For more information, see the Origin Help file. nlsf.confCol$ Read/write
string

Same as nlsf.lconfcol$. nlsf.constr$ Read/write
string

Set constraints to the fitting process. If the property is not set, the fitting module defaults to no constraints. If constraints are changed, use this property to set them again.
To clear the constraint, use an empty string, i.e., nlsf.constr$= " ";. Because Origin always stores the constraints internally, this command may be necessary to clean up the memory nlsf.constraints Read/write numeric Enable/disable the general linear constraints set by the nlsf.constr$ object property.
0 = disable constraints.
1 = enable constraints.

numeric

Read the correlation coefficient which is computed at the end of a round of iterations.

nlsf.covar$Read/write string Set a matrix that is used to store the variance-covariance matrix. nlsf.curRow Read/write numeric The current row number. Access this number in the function scripts. Note: versions prior to 3.0 store this value into the system variable i. nlsf.dataBegin Read/write numeric Set the beginning of the data range. The actual fitting is performed only on the data within this range. The default value is 1. However, when fitting from the menu, the fitting module automatically searches for the data range if it was set manually, or defaults to the entire column. For more information, see the Origin Help file. nlsf.dataEnd Read/write numeric Set the end of the data range. This value must be set if you fit from scripts, as its default value is 0. nlsf.dataStep Read/write numeric Set the data interval, which is defined as an incremental step size when only a subset of data points are used. This is a very useful feature when there are a large number of data points and you need a rough guess of the fit. 1 = every data point is used, 2 = every other data point is used, etc. When using script for fitting, this value is defaulted to 1. When you fit from the menu, this value is calculated so that only a limited number of data points are used. However, you may reset its value. nlsf.derivStep Read/write numeric Set the parameter change amount ( ) for calculating numeric derivatives. A smaller value gives higher precision but may cause numeric round-off errors. The default value is 0.005. nlsf.dn Read only numeric Read the dependency of the nth parameter. nlsf.dof Read only numeric Read the degree of freedom of the data and fitting function. For more information, see the Origin Help file. nlsf.en Read only numeric Read the standard error values of the nth parameter. nlsf.err Read only numeric Read the error code (or error message number). For more information, see the Origin Help file. nlsf.fitColNum Read only numeric Number of columns used for fitting. nlsf.fitDatan$ Read/write
string

Read or set the full name(s) of the dependent variable(s). Note: You must assign the function to nlsf.func$before you can assign the datasets to this property. nlsf.fitWksName$ Read only
string

Read the name of the worksheet that contains the fitting datasets (columns).

numeric.

Read the internal ID of the function that is selected for fitting.

nlsf.func$Read/write string Set the specified function as the fitting function. For example, nlsf.func$ = "gauss"; sets the Gaussian function as the fitting function. Note: You must specify the function with this property before assigning nlsf.fitData$. nlsf.funcCol$ Read/write
string

Set a column to store functional values (upon completion of the fitting session). This property can be used in conjunction with nlsf.xmode, nlsf.xpoints, nlsf.databegin, nlsf.dataend and nlsf.makecurve( ).

nlsf.funcx$Read/write string Set a column as the X column to create datasets. These columns are used as the independent variables when creating the end results of a fitting session. This includes the fit curve, dataset and confidence and prediction bands. Refer to: nlsf.xmode and nlsf.makecurve(). nlsf.isBadData Read only numeric Check the data: 1 = enable, 0 = disable. nlsf.isBadFunc Read only numeric Check the function selected for fitting: 1 = enable, 0 = disable. nlsf.isDialogOpen Read/write numeric Read/set the internal ID of the opened dialog box. nlsf.keepParam Read/write numeric Show if the parameters should be saved after closing the fitting session and restored before opening: 1 = enable, 0 = disable. nlsf.lbn Read/write numeric This is a vector value. For each parameter, it reads/sets the lower bound value. These are the values that are displayed in the edit boxes in the Parameter Constraints dialog box. nlsf.lbonn Read/write numeric Enable/disable use of nlsf.lbn 0 = disable. 1 = enable. nlsf.lbxn Read/write numeric This is a vector value. It reads/sets the sign of each low constraint. Value 0 corresponds to <=, value 2 corresponds to <, ... These correspond to the button values displayed in the Parameter Constraints dialog box. nlsf.lConfCol$ Read/write
string

Set a column that is used to store the values of the lower confidence band.

numeric

Read the lower confidence limit value of the nth parameter for a given confidence value (nlsf.conf).

nlsf.lPredCol$Read/write string Set a column that is used to store the values of the lower prediction band. nslf.maxIter Read/write numeric Set the maximum number of iterations that will be performed. nlsf.maxDerivStep Read/write numeric The execution of fitting requires a calculation of derivatives of a selected function. If the function is user-defined, the derivative is calculated numerically (see the Origin Help file). In this case, the maximum value of the step for the numeric derivative must be set for a "flexible (non-fixed) step" regime. So nlsf.maxderivstep contains just this value. For user defined functions, this value is read and set in the Derivative Delta group of the Control Parameters dialog box. nlsf.minDerivStep Read/write numeric See nlsf.maxderivstep. This property is for the minimum value of the step. nlsf.msgPrompt Read/write numeric Set to suppress message prompts: 1 = show all message prompts, 0 = suppress all message prompts, 2 = suppress parameter mutual dependency messages. nlsf.mu Read/write numeric Set the value for diagonal magnification of the curvature matrix. This value is very important in the Levenberg-Marquardt routine. Its default value is 0.001. nlsf.muMin Read only numeric Read the smallest MU value ever reached. nlsf.n$ Read only
string

This is a vector of strings. It contains the names of all the parameters.

nlsf.names$Read only string Same as nlsf.n$.

numeric

Read the number of constraints. The linear constraints are parsed and translated into a matrix-vector format internally with the nlsf.nconstr as the number of linear equations.

numeric

Read the number of effective constraints. If some parameters are fixed, the fitter disables them in the constraint equations by moving them from the left side of the equations to the right side. This may reduce the total number of equations. As a result, the final number of linear constraint equations may be less and is denoted as nlsf.nconstreff.

numeric

Read the number of iterations that are actually performed. Use nslf.maxIter to set the maximum number of iterations.

nlsf.noFitCurve N/A

Not currently implemented. Read/set if the curve should be constructed. See nlsf.end( ) or nlsf.makecurve( ).

numeric

Read the number of parameters that are allowed to vary. Use nlsf.vn or PVn to set the nth parameter to fixed or vary.

numeric

Read the number of data points that are actually used in the fitting. This value is the actual value used to calculate the degree of freedom (nlsf.dof) and the reduced chi-square value. Because there may be bad data points or functional evaluations, this value may be less than the user-specified value.

numeric

Read/set the total number of sets. This property should be used when fitting multiple datasets. It should be set prior to assigning the independent and dependent variables. To set variables see: nlsf.indep$, nlsf.dep$ nlsf.setDepend() nlsf.setIndep(), nlsf.y$, nlsf.fitData$ and nlsf.x$. nlsf.numIndep Read only numeric Read the total number of independent variables. nlsf.numReplica Read/write numeric Read/set the number of replicas. This value should be set to the number of peaks in your dataset minus 1. When fitting multiple peak datasets, this value is used for each dependent variable. nlsf.pasteToPlot Read/write numeric Paste results into the graph after fitting: 1 = enable, 0 = disable. The results of using this property will not be evident until the fitting session is ended. See the method nlsf.end( ) nlsf.pn Read/write numeric. Set or read the nth parameter values. If you know the names of your parameters, you can also read/write them using the parameter name. For example:  When fitting with the Gauss function, you can read/set y0, xc, w, and A. If replicas are enabled, increment each parameter name (i.e. xc1, w1, A1, ... , xcn, wn, An). Note that y0 is not incremented in this case since it is common to both peaks. Multiple datasets are incremented after an underscore. For instance, a two dataset fit where each dataset contains two peaks would yield parameters: xc1_1, w1_1, A1_1, xc2_1, w2_1, and A2_1 for the first dataset and xc1_2, w1_2, A1_2, xc2_2, w2_2, and A2_2 for the second dataset. nlsf.pred Read/write numeric Set the prediction level value. For more information, see the Origin Help file. nlsf.predCol$ Read/write
string

Same as nlsf.lpredcol$. nlsf.sn Read/write numeric Read or set parameters as shared, where n is the parameter number as it occurs in the Parameters Sharing list on the Select Dataset page. 1 = shared. 0 = not shared. nlsf.singularCriterion Read/write numeric This property is applicable when the SVD (single value decomposition) method is used for the matrix inversion. The SVD method's algorithm supposes to "ignore" (exactly, turn to 0 value = 1/element) the elements of the diagonal matrix, if these elements are very small (less than nlsf.singularcriterion). The nlsf.singularcriterion variable contains the value that should be used as a criterion of how small the element (its relative value) is. All elements smaller than nlsf.singularcriterion will be turned to 0 in the inverse matrix. By default, nlsf.singularcriterion is equal to 1e-60. nlsf.ssr Read only numeric Read the value of the sum of squares function SS(p). nlsf.status Read only numeric 0 after closing a fitting session. 1 after opening a fitting session and initializing. nlsf.tolerance Read/write numeric Set the tolerance value to stop the iterations. The tolerance value is a stop criterion. The default value is 1E-9. For more information, see the Origin Help file. nlsf.ubn Read/write numeric Same as nlsf.lb, but for the upper bound. nlsf.ubonn Read/write numeric Enable/disable use of nlsf.ubn 0 = disable. 1 = enable. nlsf.ubx Read/write numeric Same as nlsf.lbx, but for the upper bound sign. nlsf.uConfCol$ Read/write
string

Set a column that is used to store the values of the upper confidence band.

numeric

Read the upper confidence limit value of the nth parameter for a given confidence value (nlsf.conf).

nlsf.uPredCol$Read/write string Set a column that is used to store the values of the upper prediction band. nlsf.vn Read/write numeric Tells whether parameter n is fixed or allowed to vary during fitting: 1 = vary, 0 = fixed. (You can fix a parameter using linear constraints.) nlsf.wn$ Read/write
string

Set the weight column. Weights designate the contributions from individual data points. This designated column must exist before this operation can be performed. This property can be incremented using n in cases where multiple datasets are being fitted simultaneously. See also nlsf.setWeight( ).

numeric

Set weight type: 0 = no weight, 1 = instrumental, 2 = statistical, and 3 = a specified column for weighting. In general, the default value of nlsf.wtype is 0 and there is no weight. When error bars are plotted and the fitting is from the Fit menu, the weight is defaulted to instrumental type, using the error bars for weighting, with nlsf.wtype equal to 1. Otherwise, this value always defaults to no weight. For more information, see the Origin Help file.

nlsf.x$Read/write string Set the X column as the independent variable for the fitting function. You typically have an X column to plot a dataset or a function. This designated column must exist before this operation can be performed. When there is no X column, Origin uses the default worksheet X values. Set default X values using the Format:Set Worksheet X menu command. This menu command allows you to set a start value and incremental step size for Y column plotting (or fitting) when no X column exists. See also 1) nlsf.indep$ and nlsf.dep$, 2) nlsf.setDepend( ) and nlsf.setIndep( ), or 3) nlsf.y$ or nlsf.fitData$(which is often paired with nlsf.x$).

numeric

Set a start value for the curves created using the command nlsf.makecurve( ). After a fit, you may want to create a dataset with the fitting function according to the parameters found from the fitting. Use this command with nlsf.xpoints, nlsf.xstep, or nlsf.xend to create a function dataset.

numeric

Same as nlsf.xbegin but set the end value.

numeric

This value determines how to use the independent variable X when creating a function set or confidence and prediction intervals. Refer to the nlsf.makecurve() command for creating a dataset. There are several modes: nlsf.xmode = 0: Create the dataset according to the X values of the original Y dataset (the dataset which is used for fitting). In this case the X values used are those in the dependent variable's associated X column (or the Worksheet X if no X column is present). nlsf.xmode = 1: Create the dataset according to the given X starting value (nlsf.xbegin), the incremental step size (nlsf.xstep), and the total number of data points (nlsf.xpoints). In this case a specific dataset is not needed. nlsf.xmode = 2: Create the dataset according to any given X column. With this mode, you need to have an X column and set it using the command nlsf.funcx$= "xxx". The X column must exist in a worksheet somewhere in the project and contain data for this xmode to work. nlsf.xmode = 4: Create the dataset according to the first and last X values of the fitting dataset. The X values of the dataset are uniformly chosen reflecting the X-axis scale. There are nlsf.xpoints data points for this curve. With this mode, you must create an X column to store the X values. Assign this column using the command nlsf.funcx$ = "xxx". You also need to assign the number of data points using nlsf.xpoints. If you want a uniform curve on the graph with a nonlinear X-axis scale, use this command. nlsf.xmode = 5: Similar to mode 4, but create the dataset with X values starting at nlsf.xbegin and ending at nlsf.xend. Otherwise, see the previous description

numeric

Set the number of points for the fit curve dataset. Refer to nlsf.makecurve( ), nlsf.xbegin, and nlsf.xstep.

numeric

Set the incremental step size for the independent variable X for the function dataset. Refer to nlnlsf.make( ), nlsf.xbegin, and nlsf.xpoints.

nlsf.yn$Read/write string Set the Y column as the dependent variable for the fitting function. This is the dataset to be fitted. You must have this column set before you can perform any fitting operations. If you fit from the menu, Origin automatically sets the current active plotted dataset as the Y column, and its corresponding X column as the dependent variable (if there is an X column). This designated column must exist before this operation can be performed. When fitting multiple datasets, increment the dataset using n. See also nlsf.fitData$, nlsf.setDepend(), nlsf.Dep$. See related nlsf.x$, nlsf.setIndep(), nlsf.indep$. ## Methods: Method Description nlsf.addfunc(category, path, arg) Add a function to the function list in the NLSF. category = the category the function should appear under, path = the full path to the .fdf file, arg = whether to copy the function file to the functions folder ( /User Files/fitfunc/ subfolder); 0 = don't copy, 1 = copy, 2 = not ask. Note that arg is a combination of these controlling bits which produces cumulative effects. For example, to overwrite/update a function in the functions folder, set arg = 3 (includes 1 = copy function, and 2 = not ask). nlsf.begin( ) Start a fitting session. A fitting session is defined as the duration of time in which various mathematical operations can be performed, including the most important operation, the Levenberg-Marquardt minimization or the simplex minimization. In a fitting session, all storage space including the covariance matrix persists in the entire duration. nlsf.category(arg) Set the function's category. Arg is the name of the category. For example, nlsf.category(Exponential) sets the category to "Exponential" for the function's selection. Arg should have the exact spelling as the nlsf category nlsf.control(arg) ( ) Open the NLSF dialog box at the current status. (close) Close the current dialog box. (select) Open the Select Function dialog box. (dataset) Open the Select Dataset dialog box. In order to open this dialog box, you must have selected a function. (new) Open the Define New Function dialog box. (edit) Open the Edit Function dialog box. In order to open this dialog box, you must have selected a function. (fit) Open the Fitting Session dialog box. In order to open this dialog box, you must have selected a function and assigned fitting datasets. (replicas) Open the Replicas dialog box. In order to open this dialog box, you must have selected a function which allows replicas, such as the Gauss function. (simulate) Open the Simulate Curves dialog box. In order to open this dialog box, you must have selected a function. (results) Open the Generate Results dialog box. In order to open this dialog box, you must have selected a function and assigned fitting datasets. (init) Open the Initializations dialog box. In order to open this dialog box, you must have selected a function. (after) Open the After Fitting dialog box. In order to open this dialog box, you must have selected a function. (control) Open the Control Parameters dialog box. In order to open this dialog box, you must have selected a function. (constraints) Open the Parameter Constraints dialog box. In order to open this dialog box, you must have selected a function. nlsf.chkConstr( ) Check whether constraints are violated or not. This method helps you determine if the constraints are self-consistent, which may be critical for smooth fitting. nlsf.cleanUpFitData( ) Clean up all the internal objects. This method can be called at either the beginning or end of the fitting session. Its function is similar in both cases. At the beginning, nlsf.cleanupfitdata( ) can serve as a way to reset the fitting data sets if a fitting session was just performed (or you're not sure if one has) and you want to perform another one. At the end, the method serves as a way to clean up the internal data set assignments prior to ending a fitting session so that the next fit (if there is one) starts clean. Several properties remain set even after this method is executed. These include the fitting function and parameter values. This allows quicker fitting, especially from the NLSF GUI since one can reopen the NLSF after a fitting session has completed and reassign a new fit data set without having to reselect the fitting function and initialize the parameters.. nlsf.cmatrix(index1, index2) Return the value of the element of the constraint's matrix with indexes (index1, index2). Example: nlsf.cmatrix(2, 1) = ; returns the value of the element that is located in the second column and first row. nlsf.createCurves(curveType) Plot the confidence and prediction bands. If curveType = C, create confidence bands. If curveType = P, create prediction bands. The confidence and predicition levels can be from nlsf.conf and nlsf.pred. nlsf.end(n) End a fitting session. n = 8: do not paste Fit Label to results log. n = 4: do not paste Fit Label to graph. n = 1: do not create a fit curve. The argument uses a bit oriented method. In this method n= 13 ( 8+4+1) will set all three options. If n is omitted then no options are set. After this method, related internal storage space is destroyed. You can start another fitting session using nlsf.begin( ). nlsf.fit(n) Similar to nlsf.iterate(n), except this method automatically generates a fitted curve with an X dataset. In the default case the curve is generated and the data is placed in the original worksheet next to the independent variable. These datasets are generated with nlsf.xPoints number of points and the X values are evenly spaced in the current X axis space. The FitFunc datasets are not generated again if they already exist. To open the worksheet for these datasets, use the script: edit fitfunc;. nlsf.funcVal(x) Get the function value for a given independent value x. nlsf.init( ) Initialize the fitting DLL and put Origin in a status that is ready to start a fitting session. 50 parameters are allocated by default. All system variables are set to default values. This method is equivalent to selecting Action:Reset in the Advanced Fitter. nlsf.iterate(n) Iterate the fitting procedure for n iterations without creating a fit curve. This is the kernel of the fitting module, in the sense that the actual fitting routines which are the Levenberg-Marquardt minimization and the corresponding constraint routines (if there are any constraints) are used to find the parameters. If the tolerance value (see the Origin Help file) is satisfied, the fitter stops before the specified number of iterations are finished. This operation can only be done within a fitting session. If n = 0, the fitter is not activated but the reduced chi-square value as well as the fit are recalculated based on current parameters. nlsf.make( ) Same as nlsf.makecurve( ). nlsf.makecurve(type) Make datasets according to the specification type. The current implementation supports creating a fit curve dataset, confidence bands, prediction bands, and a variance-covariance matrix. The corresponding X values of these datasets are determined by nlsf.xmode. These operations succeed only after you have supplied proper column names for the generated datasets. (func) makes a function dataset according to the fitting function, the given parameters, nlsf.xmode, nlsf.xbegin, nlsf.xend, nlsf.xstep, and nlsf.xpoints. nlsf.makecurve(conf) makes confidence bands according to the fitting function, the given parameters, nlsf.xmode, nlsf.xbegin, nlsf.xend, nlsf.xstep, and nlsf.xpoints. The default confidence value is 0.95, which can be changed using nlsf.conf. See also nlsf.createCurves(C ) (pred) makes prediction bands according to the fitting function, the given parameters, nlsf.xmode, nlsf.xbegin, nlsf.xend, nlsf.xstep, and nlsf.xpoints. The default confidence value is 0.95, which can be changed using nlsf.pred. For nlsf.makecurve(func),' nlsf.makecurve'(conf), and nlsf.makecurve(pred), you must provide columns to store the resulting datasets and assign them using nlsf.funcCol$, nlsf.lPredCol$, and nlsf.uPredCol$. Depending on nlsf.xmode, you may need to provide a corresponding X column (see nlsf.xmode). (v) creates the variance-covariance matrix. Before you use this command, you must create a matrix and use nlsf.covar to set the matrix to store the variance-covariance matrix.

nlsf.pasteParams(ctrl)

Paste the parameters to the graph or Results Log. If ctrl = PLOT (or just ctrl = P), paste the parameters to the graph. If ctrl = RESULTS (or ctrl = R), paste the parameters to the Results Log.

nlsf.paraConf( )

Create the confidence intervals for individual parameters. View results using Pun for upper confidence limit of parameter n, and PLn for lower confidence limit. Use nlsf.conf = xxx; and nlsf.pred = xxx; to set the confidence and prediction levels before this command is executed. This operation can only be done within a fitting session.

nlsf.paraRange( )

Set parameters to a region that satisfies constraints if they exist. This method actually invokes constraint routines.

Nlsf.paramWks(arg)

Create the parameters worksheet. Specify the name of the worksheet to be created by entering a string (or string variable) for arg. This is equivalent to clicking the Param. Worksheet button in Action:Results or running the [ParaConf] section in Fit.OGS.

nlsf.parse( )

Parse constraints explicitly and set up related storage space for constraint operations. Constraints must be parsed before they can be used. The fitter checks for the constraints and calls this method internally if there are constraints and they are still not parsed.

nlsf.report(n) Generates a report without ending the fitting session. n = 8: do not paste Fit Label to results log. n = 4: do not paste Fit Label to graph. n = 1: do not create a fit curve. The argument uses a bit oriented method. In this method n= 13 ( 8+4+1) will set all three options. If n is omitted then no options are set.
nlsf.residuals( )

Create a residuals plot for the dependent variable.

nlsf.rsConstr( )

Not currently implemented. This method restores the constraint's value saved after the last fitting session closing.

nlsf.setDepend(VarName, Dataset)

VarName is the variable name. Dataset is the full dataset name. This method sets Dataset as the variable varName. Therefore, it has the same effect as an assignment in the Select Dataset dialog box. For example: nlsf.setdepend(act,data1_activity)

nlsf.setIndep(VarName, Dataset)

Same as nlsf.setdepend( ) but for independent variables.

nlsf.setWeight(VarName, WVarName, Dataset) VarName is the dependent variable name. WVarName is the name of the weight variable related to VarName. Dataset is the full dataset name of the column to use as a weight for VarName.
nlsf.simplex(n)

Iterate to find parameters using the simplex method, according to the specified n iterations. When parameter values are unknown at the beginning, the simplex method can be used to initialize them or to make a reasonable guess. The simplex method typically needs more functional evaluations to reach the minimum.

nlsf.svConstr( )

Not currently implemented. Save constraint values after closing a fitting session.

nlsf.unInit( )

Un-initialize the fitting module and free up all memory that was allocated during various fitting operations. This method is necessary after fitting operations which use a lot of memory due to a large number of parameters and constraints.

nlsf.updateDialog( )

Update the parameter values in the Fitting Session, Simulate, and Parameter Initialization dialog boxes. Used during a fitting session when new values for parameters are computed and need to be displayed in the dialog box.

nlsf.varCovar(index1, index2)

Used like nlsf.cmatrix( ), but for the variance-covariance matrix.

## Examples:

This script fits the first plotted dataset in the active graph window using the exponential decay 2 fitting function.

 nlsf.func$= ExpDecay2; nlsf.cleanupfitdata(); //begin fitting session nlsf.fitdata$ = %(1,@D); //fit first dataset in layer
nlsf.tolerance = 0; //set tolerance
nlsf.W$= errof(%(1,@D)); //use error bars as weight if exist if (nlsf.w$ == "")
{
nlsf.wtype = 0;
};
else
{
nlsf.wtype = 1;
};
limit %C;
nlsf.xBegin = limit.xmin; //set up x values
nlsf.xEnd = limit.xmax;
nlsf.xPoints = 1000; //number of data points for fitted curve
nlsf.fit(20); //FIT, 20 iterations

This script performs an exponential decay 2 fit on worksheet data. This example assumes a worksheet named Exp is active with columns A, B and Fit.

nlsf.func$= ExpDecay1; A1 = 10; //initialize parameter values t1 = 1; x0 = 0; y0 = 0; nlsf.cleanupfitdata(); nlsf.fitdata$ = exp_b;
nlsf.iterate(20);
nlsf.xmode = 2;
nlsf.funcx$= exp_A; //use as X dataset nlsf.funccol$ = exp_Fit; //dataset to store fitted Y values
nlsf.makecurve(func); //dataset generated for the fitted curve

This script fits two datasets (called Draw1_b and Draw2_b) to the built-in Boltzmann fitting function. First, the fitting session is set up. Next, the initial parameters for Draw1_B are defined. Third, the initial parameters for Draw2_b are defined. Finally, the fitting session is performed.

To work through the next example, you must first create the data. You can do this by opening an empty graph window and using the Draw Data tool on your Tools toolbar.

Creating two drawn datasets in this manner in a new project will automatically prepare you for this example as the datasets are named Draw1_b and Draw2_b by default. After preparing the data, execute the following script (for example, in the Script window):

// Set up the fit //
nlsf.func$= Boltzmann; // select Boltzmann fitting function nlsf.numfitsets = 2; // indicate 2 datasets to be fitted nlsf.fitdata1$ = Draw1_B; // define 1st dataset to be fitted
nlsf.fitdata2\$ = Draw2_B; // define 2nd dataset to be fitted
// Initialize parameter set for draw1_b //
nlsf.p1 = 0.1; // A1 of first dataset
nlsf.p2 = 10; // A2 of first dataset
nlsf.p3 = 4; // x0 of first dataset
nlsf.p4 = 1; // dx of first dataset
// Initialize parameter set for draw2_b //
nlsf.p5 = 0.1; // A1_2 of 2nd dataset
nlsf.p6 = 10; // A2_2 of 2nd dataset
nlsf.p7 = 8; // x0_2 of 2nd dataset
nlsf.p8 = 1; // dx_2 of 2nd dataset
// Perform the fit //
nlsf.fit(100); // iterate 100 times