Fit the curve to a polyline, where n is the number of sections, and get the average of each section optionally
bool fit_polyline( int iSize, double * px, double * py, int n, vector & slope, vector & ave = NULL, vector & cutoff = NULL, vector & xave = NULL )
Return TRUE for success, else return FALSE.
EX1
void fit_polyline_ex() { //import data into new worksheet, user may import this data manully. LT_execute("win -t W Origin;"); LT_execute("open -w %(system.path.program$)Samples\Curve Fitting\Linear Fit.dat;"); Worksheet wks = Project.ActiveLayer(); if ( wks ) { Column colX(wks, 0); Column colY(wks, 1); vector vX(colX); vector vY(colY); vector vCutoff, vSlope, vAve, vXAve; int n = 5; int nSize = vX.GetSize(); if ( fit_polyline(nSize, vX, vY, n, vSlope, vAve, vCutoff, vXAve) ) { int nSlopes = vSlope.GetSize(); for ( int ii = 0; ii < nSlopes; ii++ ) { printf("Slope[%d] = %.4lf\n", ii, vSlope[ii]); } } } }
The function used for fitting function parameter initialization.
origin.h