3.5.1.3.3 Fit

This function creates a dataset corresponding to the fitted line generated during nonlinear fitting. The parameters and equation used in the current nonlinear fit script are applied to the specified X dataset. The function returns a value for each element of the X dataset. This function is no longer valid after executing nlend. Prior to 8.0, this function was valid anytime after using the nonlinear fitter or the NLSF object.

Xdataset
The X data to be evaluated.
n
The index of fitted curve. Default = 1.
Example
You can perform a Gauss fit on data with an X range, then generate a new fit curve using the following lines of script:
// import sample data into a new book
newbook;
fname$=system.path.program$+"Samples\Curve Fitting\Multiple Gaussians.dat";
impASC;

// Start a fitting session
nlbegin ((1,2),(1,3)) Gauss tt;
// Fit
nlfit; // Fit till converge (default iterations)

// Generate the fit curve
range xx = 6, yy = 7;
xx = data(-20,80,0.25);
//Indicates using the second dataset's parameter values to perform NL Fit.
yy = fit(xx,2); 
xx[L]$ = "Fitted X";
yy[L]$ = "Fitted Y";
xx.type = 4; // Make it an X col
nlend; // fit() function is no longer valid

// plot both src and fit in a new graph
range aa = (1,2), bb=(6,7);
plotxy aa 201 ogl:=[<new>];
plotxy bb 200 ogl:=1!; // plot to same layer