OriginLab Corporation - Data Analysis and Graphing Software - 2D graphs, 3D graphs, Contour Plots, Statistical Charts, Data Exploration, Statistics, Curve Fitting, Signal Processing, and Peak Analysis                     
Skip Navigation Links
All BooksExpand All Books
Quick HelpExpand Quick Help
ProgrammingExpand Programming

4.13 FAQ-372 How do I access analysis result table values from script?

Last Update: 2/3/2015

Analysis operations such as Linear and Nonlinear Fit create report sheets that contain embedded tables with the fit results such as fit statistics and parameter values. These results can be accessed from script using X-Functions provided for this purpose.

For general use with any report sheet, you may use the getresults X-Function.

For example:

// create a tree variable of the results in the active result sheet
getresults myLRFitResults;

// Output a list of properties

// if linear fit, can return the slope value by:

If you are working with the nonlinear curve fitter, there is a an X-Function specifically designed for use with nonlinear fitting results: getnlr X-Function. With this X-Function, the tree structure is simpler, and options are provided to customize accessing the result by parameter name instead of index etc.

For example, put the following script, which has used the __REPORT$ system variable to find report sheet, to the "After Fit" script section of your FDF file, so to output some fitting values after fitting.

getnlr myfit iw:=__REPORT$ p:=2;
type %(myfit.func$) fit of %(myfit.Data1.y1$) results:;
for( int ii=1; ii<=myfit.nfuncparams; ii++)
    val = myfit.p$(ii);
    err = myfit.e$(ii);
    type Parameter $(ii) \x3D $(val) +/- $(err);


  • The contents of the created tree can be viewed from the LabTlk Variables and Functions dialog (opened by ed command).
  • __REPORT$ may not be useful in Set Column Values since its value is changed when another analysis runs.
  • To get the number of datasets, use the nsets value of the tree. And nfuncparams and nderivparams are the number of parameters and derived parameters respectively.
  • You can choose Parameter Names (Option 0), Abbreviations (Option 1) or both (Option 2) as notation of parameters for the output tree. For Option 0, the names and errors of parameters are enumerated like P1, E1, P2, E2, etc. And for Option 1, errors and names are prefixed with e_ and n_ respectively, such as, y0_1, e_y0_1, n_y0_1, y0_2, e_y0_2, n_y0_2, etc.

In the following script, suppose there is a global fitting result of two datasets by Boltzmann function, which has A1 and A2 as parameters P1 and P2, then we use the getnlr X-Function to get the report tree with both name notations.

getnlr myfit iw:=FitNL1! p:=2;
FirstAsymptoteA1 = myfit.p1; // Alternative name is A1_1
FirstAsymptoteA2 = myfit.p2; // Alternative name is A2_1
SecondAsymptoteA1 = myfit.A1_2; // Alternative name is p5
SecondAsymptoteA2 = myfit.A2_2; // Alternative name is p6

Keywords:after, fit, nlfit, nonlinear, curve, parameter, result, getnlr


© OriginLab Corporation. All rights reserved.