2.1.23.2.12 ocmath_find_peaks_partition
Description
Find two inflexions determined by smoothed 2nd derivative on the nearest left and right of dPeakCenter,
and then use nStartofPeak and nEndofPeak to record the two inflexions indices.
nStartofPeak and nEndofPeak determined the peak's partition.
Syntax
int ocmath_find_peaks_partition( UINT lSize, const double * px, const double * py, double dPeakCenter, int * nStartofPeak, int * nEndofPeak, int nPtsSmooth )
Parameters
- lSize
- [input] size of px, py
- px
- [input] it contains curve's X coordinate's datas
- py
- [input] it contains curve's Y coordinate's datas
- dPeakCenter
- [input] X coordinate's data of peak's center
- nStartofPeak
- [output] pointer to the start indice of peak
- nEndofPeak
- [output] pointer to the end indice of peak
- nPtsSmooth
- [input] the number of smooth points
Return
Return OE_NOERROR if succeed, otherwise, non-zero error code is returned.
Examples
EX1
//Assume in the current graph, curve's XY data is in the first data plot. This piece
//of code get the XY data of the curve from the first data plot and find the peaks.
void ocmath_find_peaks_partition_ex1()
{
GraphLayer gl = Project.ActiveLayer();
if (!gl)
{
return;
}
//get data from the first dataplot
DataPlot dp = gl.DataPlots(0);
DataRange dr;
vector vxData, vyData;
if(dp.GetDataRange(dr))
{
DWORD dwPlotID;
if(dr.GetData(DRR_GET_DEPENDENT | DRR_NO_FACTORS, 0, &dwPlotID, NULL, &vyData, &vxData) < 0)
{
printf("get_plot_data failed GetData");
return;
}
}
uint lSize = vxData.GetSize();
int nStart, nEnd;
double dPeak=4;
int nPtsSmooth=11;
int nRet = ocmath_find_peaks_partition(lSize, vxData, vyData, dPeak,&nStart,&nEnd, nPtsSmooth);
if( nRet < OE_NOERROR )
{
printf("error code: %d\n", nRet);
return;
}
}
Remark
See Also
Header to Include
origin.h
Reference
|