2.8.1 avecurves


Menu Information

Analysis : Mathematics : Average Multiple Curves

Brief Information

Average or concatenate multiple curves

Command Line Usage

1. avecurves iy:=(Plot(1),Plot(2)) method:=concatenate; 
2. avecurves iy:=((1,2),(3,4)) method:=ave avex:=common interp:=linear; 

X-Function Execution Options

Please refer to the page for additional option switches when accessing the x-function from script

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Input iy

Input

XYRange

<active>
Specifies multiple curves to be averaged or concatenated. Note that beginning with Origin 2020b, there is a shortened syntax that follows the form [Book]Sheet!(X,Y1:YN), X = the common X column and Y1:YN = a contiguous range of Y columns to the right of the X column. More complex strings from non-contiguous data of the form [Book]Sheet!((X,Y1:YN),(X,YM:YO)) are also possible.
Method method

Input

int

0
Specifies the method.

Option list:

  • ave:Average {0}
    Average the input curves.
  • concatenate:Concatenate {1}
    Concatenates the input curves.
Averaged X avex

Input

int

2
This is available only when Average is selected for the Method. It specifies the method to compute the X values of the averaged curve.

Option list:

  • same:Same as Source X {0}
    Use the X values of all input curves as the averaged X. X values within tolerance which is specified by Tolerance for Common X Values will be treated as a same x and averaged.
  • common:Common X Range {1}
    Compute the X values of the averaged curve in the common X range of input curves. Create an X dataset of npts from the largest minimum X of all datasets to the smallest maximum X and computes an average of Y values based on the interpolation method.
  • full:Full X Range {2}
    Compute the X values of the averaged curve in the full X range of the input curves. Create an X dataset of npts from the smallest minimum X of all datasets to the largest maximum X and computes an average of Y values based on the interpolation method.
  • custom:Custom {3}
    Compute the X values of the averaged curve in the X range which you have customized in X Minimum and X Maximum. Create an X dataset of npts from the chosen X Minimum to the chosen X Maximum and compute an average of Y values based on the interpolation method.
  • trace:Follow Curve Trace {4}
    Compute the X values of the averaged curve by trace interpolation, which can create a new curve which has a similar shape to the input curves. For more details, please refer to the Algorithm.
Tolerance for Common X Values toler

Input

double

1e-8
This is available only when Same as Source X is selected for Averaged X. It is used to check if the X values of input curves are the same. Two, different X values are considered the same if abs(X1 - X2) <
Number of Points npts

Input

int

<auto>
This is available when Averaged X is not set to Same as Source X. It specifies the number of evenly spaced X points from X Minimum to X Maximum to get Y values based on the chosen Interpolate method. If Averaged X is Custom you can uncheck the Auto checkbox and specify the minimum or maximum values.
X Minimum xmin

Input

double

<auto>
This is editable only when Custom is selected for Averaged X. It is read-only for Common X Range and Full X Range. It specifies the minimum X value of the averaged curve. It computes a number automatically if the Auto checkbox is enabled. You can also disable the Auto checkbox and specify the values.
X Maximum xmax

Input

double

<auto>
This is editable only when Custom is selected for Averaged X. It is read-only for Common X Range and Full X Range. It specifies the maximum X value of the averaged curve. It computes a number automatically if the Auto checkbox is enabled. You can also disable the Auto checkbox and specify the values.
Interpolate interp

Input

int

0
This is available only when Averaged X is not set to Same as Source X. It specifies a method to interpolate the Y values when averaging.

Option list:

  • linear:Linear
    Performs linear interpolation on the Y values.
  • spline:Spline
    Performs spline interpolation on the Y values.
  • bspline:B-Spline
    Performs B-Spline interpolation on the Y values.
No Extrapolation extrap

Input

int

1
This is available only when Averaged X is not set to Full X Range, Custom, and Follow Curve Trace. It is used to specify whether to extrapolate the curves when these curves have different X ranges.
Sort X sortx

Input

int

1
This is available only when Concatenate is selected for Method. It specifies the method to sort the X values of the averaged curve. Y values will be reordered accordingly.

Option list:

  • none:None
    Do not sort the X values.
  • ascend:Ascending
    Sort the X values ascending.
  • descend:Descending
    Sort the X values descending.
Std Dev sd

Input

int

0
This variable is available only when the Method variable is set to Average. It specifies whether or not to compute the standard deviations of the averaged curve.
Std Err se

Input

int

0
This variable is available only when the Method variable is set to Average. It specifies whether or not to compute the standard errors of the averaged curve.
N n

Input

int

0
This variable is available only when the Method variable is set to Average. It specifies whether or not to compute the counts of input data points that correspond to each averaged X value.
Minimum min

Input

int

0
This variable is available only when the Method variable is set to Average. It specifies whether or not to output the minimum value.
Maximum max

Input

int

0
This variable is available only when the Method variable is set to Average. It specifies whether or not to output the maximum value.
SD times 2 sd2

Input

int

0
This variable is available only when the Method variable is set to Average. It specifies whether or not to compute the standard deviation times 2.
SD times 3 sd3

Input

int

0
This variable is available only when the Method variable is set to Average. It specifies whether or not to compute the standard deviation times 3.
Output rd

Output

ReportData

[<input>]<new>
Specifies the output data.

Examples

  • To concatenate two input curves (the first two plots of the active graph layer), type the following script command in the Command Window:

avecurves iy:=(plot(1), plot(2)) method:=concatenate;

  • Code Sample
/*
This example shows how to average multiple XY data that are
monotonic in X but do not necessarily share X values.
The sample data used is in
  OriginPath\Samples\Spectroscopy\DSC\Data folder
1. Load the data to different worksheets of the same book
2. use avecurves XF to average the A(X)B(Y) of all the sheets.
3. put the result into a new sheet
4. Plot the original into one graph and the averaged data into another graph
*/
// Load the sample data to separated sheets, using existing 
// loadDSC.ogs
string LoadDSCogsPath$=system.path.program$ + "Samples\LabTalk Script Examples\LoadDSC.ogs";
%A=LoadDSCogsPath$;
if(!run.section(%A, Main, 0))
	break 1;
// Data should be loaded now into active book
string dscBook$=%H;
// plot all the data A(X), B(Y) first
plotxy [dscBook$](1:end)!(1,2) plot:=200;

// Perform average on all the sheets data using interp average method with linear interpolation
avecurves iy:=[dscBook$](1:end)!(1,2) rd:=[<input>]<new name:="Averaged Data">! method:=ave interp:=linear;
// plot the averaged as well
plotxy [dscBook$]"Averaged Data"!(1,2) plot:=200 ogl:=[<new>]<new>!;

More Information

Please refer to this page in the User Guide for more information:

  • Description
  • Algorithm



Related X-Functions

averagexy