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 myLRFitResults.=; // if linear fit, can return the slope value by: myLRFitResults.Parameters.Slope.Value=;
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); }
Notes:
ed command).
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