area

 

Description

Get the area under a curve.

Syntax

double area( Curve & crv, double dYoffset = 0 )

Parameters

crv
[input] Origin C Curve object
dYoffset
[input]Y offset subtracted from curve

Return

Returns the area under a curve.

Examples

EX1

// This is a self contained sample program for the function area, 
// Its sample data is created at the beginning of the program. 
// To run the program, enter the following command in the Script window:
//   area_ex1
// This will return the result like following:
//   Area under the Plot Y:Data12_B over X:Data12_A (Offset=0.5) = 1.000000
void area_ex1()
{
    double dArea;
    Worksheet wks;
    wks.Create();
    Dataset myXDs(wks,0);
    String strXName = myXDs.GetName();
    Dataset myYDs(wks,1);
    String strYName = myYDs.GetName();

    //******* Create sample data *****************
    myXDs.SetSize(3);
    myYDs.SetSize(3);
    myXDs[0]=0;    myYDs[0]=0.5; 
    myXDs[1]=1;    myYDs[1]=1.5; 
    myXDs[2]=2;    myYDs[2]=0.5;
    double dOffset = 0.5;
    //******** End of Sample Data Creation *******
    
    Curve myCrv(myXDs,myYDs);

    dArea = area(myCrv, dOffset);  // Demonstration of area

    printf("Area under the Plot Y:%s over X:%s (Offset=%g) = %f\n",
        strYName,strXName,dOffset,dArea);
}

Remark

The function used for fitting function parameter initialization.

See Also

header to Include

origin.h

Reference