# 2.1.17.2.2.3 Curve_x

## Description

Get X value of Curve at specified index.

## Syntax

double Curve_x( curvebase * pcrvData, int nIndex )

## Parameters

pcrvData
[input] Pointer to Curve
nIndex
[input] Zero based index

## Return

For given Curve returns value of X at specified value of nIndex.

If the given index is out of the range of the dataset, it returns NANUM.

## Examples

EX1

// This is a self contained sample program for the function Curve_x,
// Its sample data is created at the beginning of the program.
// To run the program, enter the following command in the Script window:
//   Curve_x_ex1
// It returns like the following three lines:
//   Find X at Row#3 ==> FOUND: 4

void Curve_x_ex1()
{
double dXatI;
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

int nIndex=2;       // 0-based index
dXatI = Curve_x(&crvData,nIndex);    // Demonstration of Curve_x
if(dXatI!=NANUM)
printf( "Find X at Row#%d ==> FOUND: %g\n",nIndex+1,dXatI); // Row#=nIndex+1
else
printf( "Find X at Row#%d ==> NOT FOUND\n",nIndex+1); // Row#=nIndex+1
}

## Remark

The function used for fitting function parameter initialization.

origin.h