Curve_xfromY

 

Description

Get interpolated/extrapolated X value of Curve at specified Y value.

Syntax

double Curve_xfromY( curvebase * pcrvData, double dY )

Parameters

pcrvData
[input] Pointer to Curve
dY
[input] Value of Y

Return

For given Curve returns interpolated/extrapolated value of X at specified value of Y.

Since the function uses extrapolation/interpolation, the out-of-range error will not occur.

Examples

EX1

// This is a self contained sample program for the function Curve_xfromY, 
// Its sample data is created at the beginning of the program. 
// To run the program, enter the following command in the Script window:
//   Curve_xfromY_ex1
// It returns like the following two lines, one for interpolation, and the 
// other for extrapolation:
//  Find X at y=6.000000 ==> FOUND: x=3.000000
//  Find X at y=20.000000 ==> FOUND: x=10.000000

void Curve_xfromY_ex1()
{
    double dXfromY, dY;
    Worksheet wks;
    wks.Create();
    Dataset myXDs(wks,0);
    Dataset myYDs(wks,1);
    
    //******* Create sample data *****************
    myXDs.SetSize(4);
    myYDs.SetSize(4);
    myXDs[0]=1;    myYDs[0]=2;
    myXDs[1]=2;    myYDs[1]=4;
    myXDs[2]=4;    myYDs[2]=8;
    myXDs[3]=8;    myYDs[3]=16;
    //******** End of Sample Data Creation *******
    
    Curve crvData( myXDs, myYDs );    // Create Curve object
    
    dY=6.0;
    dXfromY = Curve_xfromY(&crvData,dY); // Demonstartion of Curve_xfromY
    printf( "Find X at y=%f ==> FOUND: x=%f\n",dY,dXfromY);

    dY=20.0;
    dXfromY = Curve_xfromY(&crvData,dY); // Demonstartion of Curve_xfromY
    printf( "Find X at y=%f ==> FOUND: x=%f\n",dY,dXfromY);
}

Remark

The function used for fitting function parameter initialization.

See Also

Curve_yfromX

Header to Include

origin.h

Reference