2.1.23.2.5 ocmath_find_inflection_point


Description

Find x coordinate of the inflection points for the peak data by an iterative method and calculate the peak width at base

Syntax

int ocmath_find_inflection_point( UINT lSize, const double * px, const double * py, double xc, double w, double * pLeft, double * pRight, double * pBottomWidth )

Parameters

lSize
[input] size of the data
px
[input] pointer to x coordinates of the data
py
[input] pointer to y coordinates of the data
xc
[input] peak position
w
[input] evaluation of the inflection position
pLeft
[output] inflection position in the left of the peak position
pRight
[output] inflection position in the right of the peak position
pBottomWidth
[output] the width of the peak between its two feet

Return

Return OE_NOERROR if succeed, otherwise, non-zero error code is returned.

Examples

EX1

void ocmath_find_inflection_point_ex1()
{
    // the full Peak data with peak position xc=4
    vector vx = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; 
        // x should be in increasing order
    vector vy = {8.15988E-4,
                0.01832,
                0.16901,
                0.64118,
                1,
                0.64118,
                0.16901,
                0.01832,
                8.15988E-4,
                1.49453E-5}

    // the left inflection point will be searched in the range restricted between xc-3w and xc
    // and its initial start position is xc-w/2
    // Similarly the right inflection point in the range between xc and xc+3w with an initial position xc+w/2
    // So you may need to supply a good w value in order to get a good inflection coordinate value as it is an iterative method
    
    double left; // left and right are the x coordinate of the inflection points
    double right;
    double width; // peak width at base

    ocmath_find_inflection_point(vx.GetSize(), vx, vy, 4, 2, &left, &right, &width);
}

EX2

//Before running, make sure the active layer is a worksheet with two columns containing the X/Y data 
void ocmath_find_inflection_point_ex2()
{
    // get the peak data from a Origin Worksheet
    Worksheet wks=Project.ActiveLayer();
    if(!wks)
        printf("no active worksheet found\n");    
    Dataset dsSrcX(wks,0);
    Dataset dsSrcY(wks,1);
    
    // convert the datasets to vectors
    int nSize=dsSrcY.GetSize();
    vector vecX(nSize);
    vector vecY(nSize);
    vecX=dsSrcX;
    vecY=dsSrcY;
    

    double xc=0.0,w=4.236;  // supply your own parameters according to the input data
    double dLeft, dRight, dBottomWidth;
    
    ocmath_find_inflection_point(nSize, vecX, vecY, xc, w, &dLeft, &dRight, &dBottomWidth);
    printf("%f  %f %f\n",dLeft, dRight, dBottomWidth);
}

Remark

See Also

Header to Include

origin.h

Reference