Average-Curves
Average CurvesMultiple curves (XY data pairs) can be averaged to create a single curve, using the avecurves X-Function. This X-Function provides several options such as using the input X values for the output curve, or generating uniformly spaced X values for the output and then interpolating the input Y data before averaging.
The following example demonstrates averaging with linear interpolation:
// Load sample data using existing 'loadDSC.ogs' script string fpath$ = "Samples\LabTalk Script Examples\LoadDSC.ogs"; string LoadPath$=system.path.program$ + fpath$; // If the data does not load properly, then stop script execution. if(!run.section(%(LoadPath$), Main, 0)) break 1; // Data should now be loaded now into the active workbook ... // Get the name of the active workbook, %H points to the active workbook string dscBook$=%H; // Perform average on all data using linear interpolation avecurves iy:=[dscBook$](1:end)!(1,2) rd:=[<input>]<new name:="Averaged Data">! method:=ave interp:=linear;
Once averaged, the data and the result can be plotted:
// plot all the data and the averaged curve, using the plotxy X-Function: plotxy [dscBook$](1:end)!(1,2) plot:=200;