📄 data.h
字号:
bPaintShade=TRUE shades area of graph between integrated Curve and X axis (or baseline)
Return:
Returns TRUE if integration is successful and FALSE otherwise. Also returns a pointer to an IntegrationResult
structure (see OC_types.h) and a pointer to dataset holding the cumulative integration result.
*/
BOOL Curve_integrate(curvebase* pcrvData, IntegrationResult* pirResult, curvebase* pcrvBaseline=NULL, Dataset* pdsIntegral=NULL, BOOL bPaintShade=FALSE); // Integrate the given Curve.
/** >Analysis
Get X value of Curve at specified index.
Example:
double dXatI;
Curve crvMyCurve( "Data1_A", "Data1_B" ); // Create Curve object
dXatI = Curve_x( &crvMyCurve, 2 ); // Get X value at 0 based index I=2
printf( "X at I=2:\t%f\n", dXatI );
Parameters:
pcrvData=Pointer to Curve
nIndex=Zero based index
Return:
For given Curve returns value of X at specified value of nIndex.
SeeAlso:
Curve_y, Curve_xfromY, Curve_yfromX
*/
double Curve_x(curvebase* pcrvData, int nIndex); // Get X value of Curve at specified index.
/** >Analysis
Get Y value of Curve at specified index.
Example:
double dYatI;
Curve crvMyCurve( "Data1_A", "Data1_B" ); // Create Curve object
dYatI = Curve_y( &crvMyCurve, 2 ); // Get Y value at 0 based index I=2
printf( "Y at I=2:\t%f\n", dYatI );
Parameters:
pcrvData=Pointer to Curve
nIndex=Zero based index
Return:
For given Curve returns value of Y at specified value of nIndex.
SeeAlso:
Curve_x, Curve_xfromY, Curve_yfromX
*/
double Curve_y(curvebase* pcrvData, int nIndex); // Get Y value of Curve at specified index.
/** >Analysis
Get interpolated/extrapolated X value of Curve at specified Y value.
Example:
double dXfromY;
Curve crvMyCurve( "Data1_A", "Data1_B" ); // Create Curve object
dXfromY = Curve_xfromY( &crvMyCurve, 0.25 ); // Get X value at Y=0.25
printf( "X from Y=0.25:\t%f\n", dXfromY );
Parameters:
pcrvData=Pointer to Curve
dY=Value of Y
Return:
For given Curve returns interpolated/extrapolated value of X at specified value of Y.
SeeAlso:
Curve_y, Curve_x, Curve_yfromX
*/
double Curve_xfromY(curvebase* pcrvData, double dY); // Get interpolated/extrapolated X value of Curve at specified Y value.
/** >Analysis
Get interpolated/extrapolated Y value of Curve at specified X value.
Example:
double dYfromX;
Curve crvMyCurve( "Data1_A", "Data1_B" ); // Create Curve object
dYfromX = Curve_yfromX( &crvMyCurve, 3.0 ); // Get Y value at X=3.0
printf( "Y from X=3.0:\t%f\n", dYfromX );
Parameters:
pcrvData=Pointer to Curve
dX=Value of X
Return:
For given Curve returns interpolated/extrapolated value of Y at specified value of X.
SeeAlso:
Curve_y, Curve_x, Curve_xfromY
*/
double Curve_yfromX(curvebase* pcrvData, double dX); // Get interpolated/extrapolated Y value of Curve at specified X value.
/** >Analysis
Create a B Spline curve with optional weighting. The smoothness parameter can either be an arbitrary value
>= 0 or an enumerated constant. The resulting B Spline curve will copy the source X data set if an empty
X data set is provided or it will use a specified X data set as long as the range is within the source X range.
Sample Data:
57.93992 83.52885
66.22726 75.17097
70.83567 87.96739
72.25362 91.59955
72.39297 81.93563
76.73526 89.47048
77.71110 67.86902
Example:
// Assumes Data1_A and Data1_B exist and contain Sample Data
// Assumes Data2_A and Data2_B exist
Worksheet wks("Data1");
Curve crvInput(wks,0,1);
Worksheet wks2("Data2");
Curve crvResult(wks2,0,1);
Curve_bspline(&crvInput, &crvResult);
Parameters:
pcrvData=Input source curve
pcrvResults=Output result curve
dSmoothness=Smoothness factor can be any arbitrary value >= 0 or a predefined constant (BSPLN_AUTO=-3,
BSPLN_INTERPOLATE and BSPLN_WEIGTHED_LEAST_SQUARE_POLYNOMIAL) enumerated in OC_const.h. The
enumerated constants are negative numbers to distinguish them from arbitrary smoothness factors.
pdsWeights=Dataset containing weights for the input curve. If not NULL the number of points in the weight
data set must equal the number of points in the source curve. The default weighting is 1 for all points.
Return:
Returns zero on successful exit and a non-zero error code on failure.
Errors:
-1=System can not allocate enough memeory
-2=Curve data type error
-4=The result curve range can not be set
5=The smoothness parameter must be equal to or greater than 0
11=The number of data points is less than 4
63=The sequence of X in source data is not increasing
73=Memory allocation failed
240=The weights are not all positive
254=The smoothness parameter is too small
SeeAlso:
Curve_derivative
*/
int Curve_bspline(curvebase* pcrvData, curvebase* pcrvResults, double dSmoothness = BSPLN_AUTO, Dataset* pdsWeights = NULL); // Create a B Spline curve with optional weighting.
/** >Analysis
Create the n-th Order derivative of a source curve with optional weighting.
Remarks:
The smoothness parameter can either
be an arbitrary value >= 0 or an enumerated constant. The resulting derivative curve will copy the source X data set
if an empty X data set is provided or it will use a specified X data set as long as the range is within the source
X range.
Please note that in Origin 7.0, the defualt argument dSmoothness was BSPLN_AUTO, in 7.5 it was changed to BSPLN_OFF.
Example:
// assumes data already in col(A), col(B)
Worksheet wks = Project.ActiveLayer();
Curve crvInput(wks,0,1);
int nXCol, nYCol;
Column cx = wks.Columns("DerivX");
if(!cx)
nXCol = wks.AddCol("DerivX");
else
nXCol = cx.GetIndex();
wks.Columns(nXCol).SetType(OKDATAOBJ_DESIGNATION_X);
Column cy = wks.Columns("DerivY");
if(!cy)
nYCol = wks.AddCol("DerivY");
else
nYCol = cy.GetIndex();
Curve crvResult(wks,nXCol,nYCol);
out_int("num of Rows before call = ", crvResult.GetSize());
Curve_derivative(&crvInput, &crvResult);
crvResult.Update(TRUE);// this will update the crvResult object to internal values inside Origin, that has been modified by Curve_derivative
out_int("num of Rows after call = ", crvResult.GetSize());
Parameters:
pcrvData=Input source curve
pcrvResults=Output result curve
nOrder=The order of the derivative
dSmoothness=Smoothness factor can be any arbitrary value >= 0 or a predefined constant (BSPLN_AUTO,
BSPLN_INTERPOLATE and BSPLN_WEIGTHED_LEAST_SQUARE_POLYNOMIAL, BSPLN_OFF) enumerated in OC_const.h. The
enumerated constants are negative numbers to distinguish them from arbitrary smoothness factors.
pdsWeights=Dataset containing weights for the input curve. If not NULL the number of points in the weight
data set must equal the number of points in the source curve. The default weighting is 1 for all points.
if dSmoothness equals BSPLN_OFF, only the first order derivative will be calculated.
Return:
Returns zero on successful exit and a non-zero error code on failure.
Errors:
-1=System can not allocate enough memeory
-2=Curve data type error
-4=The result curve range can not be set
5=The smoothness parameter must be equal to or greater than 0
11=The number of data points is less than 4
63=The sequence of X in source data is not increasing
73=Memory allocation failed
240=The weights are not all positive
254=The smoothness parameter is too small
SeeAlso:
Curve_bspline
*/
int Curve_derivative(curvebase* pcrvData, curvebase* pcrvResults, int nOrder = 1, double dSmoothness = BSPLN_OFF, Dataset* pdsWeights = NULL ); // Create the n-th Order derivative of a source curve with optional weighting.
/** >Analysis
Get X and Y range of the Curve
Example:
double x1, x2;
Curve cuv( "Data1_A", "Data1_B" ); // Create Curve object
if(Curve_MinMax(&cuv, &x1, &x2))
printf("%s X range is from %f to %f\n", cuv.GetName(), x1, x2);
Parameters:
pcuvData=Pointer to Curve
pxMin = pointer to double for X min, NULL if no need to get this value
pxMax = pointer to double for X max, NULL if no need to get this value
bScanData = TRUE will scan both XY dataset of the curve for min and max, FALSE will reuse internal cached values. Typically there is no need to scan unless data has changed
pyMin = pointer to double for Y min, NULL if no need to get this value
pyMax = pointer to double for Y max, NULL if no need to get this value
Return:
True for success
SeeAlso:
Data_sum
*/
BOOL Curve_MinMax(const curvebase* pcuvData, double* pxMin, double* pxMax, BOOL bScanData=FALSE, double* pyMin=NULL, double* pyMax=NULL);
/** >Analysis
Get the value of the specified dependent variable for the specified value of the independent variable. This function
is used in conjunction with the internal Origin Non-linear Least Squares Fitter (NLSF) object and uses the most recent
fitting function and parameter values specified through the NLSF interface or through script.
Sample Data:
2 10.54362
4 8.85013
6 7.51005
8 6.23363
10 5.31886
12 5.04538
14 5.47292
16 5.6315
18 5.09736
20 4.94923
22 5.10317
24 5.02472
Example:
// Assumes the Sample Data has been plotted in an Origin graph and has just been fit
// using the Origin Analysis:Fit Exponential Decay:First Order menu item
double dDVal,dIVal = 7.22;
dDVal = nlfFit( dIVal );
printf("The value of the fit curve at x = %g is y = %g", dIVal, dDVal );
Parameters:
dx=Input value of the independent variable
nDepend=Input dependent variable (0 based offset)
Return:
Returns the value of the specified dependent variable for the given value of the independent variable.
SeeAlso:
nlfXfromY
*/
double nlfFit(double dx, int nDepend = 0); // Get the value of the specified dependent variable for the specified value of the independent variable.
/** >Analysis
Get the value(s) of the independent variable for the specified value of the specified dependent variable. This
function is used in conjunction with the internal Origin Non-linear Least Squares Fitter (NLSF) object and uses
the most recent fitting function and parameter values specified through the NLSF interface or through script.
Sample Data:
2 10.54362
4 8.85013
6 7.51005
8 6.23363
10 5.31886
12 5.04538
14 5.47292
16 5.6315
18 5.09736
20 4.94923
22 5.10317
24 5.02472
Example:
// Assumes the Sample Data has been plotted in an Origin graph and has just been fit
// using the Origin Analysis:Fit Exponential Decay:First Order menu item
int nMaxX=1; // 1st Order exponentional decay funtion is 1 to 1 so there is only 1 independent value per dependent value
double dDVal = 8.067, dIVal;
int iErr;
iErr = nlfXfromY( dDVal, &dIVal, nMaxX );
printf("The value of x where y = %g is %g", dDVal, dIVal );
Parameters:
dy=Input value of the dependent variable
parX=Output array for the x values
nMaxX=Size of array pointed to by parX
nDepend=Input dependent variable (0 based offset)
Return:
Returns 1 if successful and returns the value(s) of the independent variable for the given value of the
dependent variable.
SeeAlso:
nlfFit
*/
int nlfXfromY(double dy, double* parX, int nMaxX, int nDependent=0); // Get the value(s) of the independent variable for the specified value of the specified dependent variable.
/** >Analysis
Copy a range of data from one data set to another. If need be the destination data set will be automatically
resized.
Example:
Worksheet wks = Project.ActiveLayer();
Dataset ds1(wks,0);
Dataset ds2(wks,1);
// Copy from row 3 to row 10 of column 1 into row 20 to 27 of column 2
Data_copy(&ds2, &ds1, 2, 9, 19);
Parameters:
pdsDest=Input pointer to destination data set
pdsSrc=Input pointer to source data set
nSrcFrom=Input starting index of the source data set (0 based offset)
nSrcTo=Input ending index of the source data set (0 based offset, default -1 copies to upper index)
nDestFrom=Input starting index of the destination data set (0 based offset, default -1 uses nSrcFrom)
bIgnoreMask=TRUE ignores masking in source data set, FALSE copies masked values as missing values
Return:
Returns TRUE if successful and FALSE if:
1) nSrcFrom < 0 or nSrcFrom > source UpperIndex
2) nSrcTo < nSrcFrom or nSrcTo > UpperIndex
3) nDestFrom < -1 (-1 means to use nSrcFrom)
*/
BOOL Data_copy(Dataset* pdsDest, Dataset* pdsSrc, int nSrcFrom = 0, int nSrcTo=-1, int nDestFrom=-1, BOOL bIgnoreMask=TRUE); // Copy a range of data from one data set to another.
#if _OC_VER > 0x0703
/** >Plotting
get dataset From and Step values that are used for plotting with Row# as X
Example:
double dFrom, dStep;
string str = "Data1_b";
if(GetDatasetXFromStep(str, &dFrom, &dStep))
printf("%s is a loose dataset, or its worksheet has No X column, so it has From/Step = %g/%g\n", str, dFrom, dStep);
Parameters:
lpcszDatasetName = [in] Dataset name
double = [out] plotting X from
lpdbStep =[out] plotting X increment
Return:
Returns TRUE if the given dataset is a valid dataset and it is in a worksheet with no X column, or is a loose dataset, so the From/Step values are available,
*/
BOOL GetDatasetXFromStep(LPCSTR lpcszDatasetName, double* lpdbFrom, double* lpdbStep);
#endif // _OC_VER > 0x0703
#endif //_DATA_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -