# 2.1.17.2.2.13 yatxmax

## Description

Get the value of Y at the maximum X value of a curve.

## Syntax

double yatxmax( Curve & crv )

## Parameters

crv
[input] Origin C Curve object; The given X dataset should be monotonic.

## Return

Returns the value of Y at the maximum X value of a curve.

## Examples

EX1

// This is a self contained sample program for the function yatxmax,
// Its sample data is created at the beginning of the program.
// To run the program, enter the following command in the Script window:
//   yatxmax_ex1
// This will return the result like following:
//   Y(Data2_B) at Maximum of X(Data2_A) = 0.44514

void yatxmax_ex1()
{
double dYatXmax;

Worksheet wks;
wks.Create();
Dataset myXDs(wks,0);   // X dataset should be monotonic
String strXName = myXDs.GetName();
Dataset myYDs(wks,1);
String strYName = myYDs.GetName();

//******* Create sample data *****************
myXDs.SetSize(8);
myYDs.SetSize(8);
myXDs=1;    myYDs=0.3;
myXDs=2;    myYDs=0.097;
myXDs=3;    myYDs=0.41256;
myXDs=4;    myYDs=0.24909;
myXDs=5;    myYDs=0.47304;
myXDs=6;    myYDs=0.2476;
myXDs=7;    myYDs=0.64529;
myXDs=8;    myYDs=0.44514;
//******** End of Sample Data Creation *******

Curve myCrv(myXDs,myYDs);    // Create a Curve object

dYatXmax = yatxmax(myCrv);  // Demonstration of yatxmax

printf("Y(%s) at Maximum of X(%s) = %g\n",strYName,strXName,dYatXmax);
}

## Remark

The function used for fitting function parameter initialization.