LabWindows/CVI

Content Type
Programming Language
Current manual

PolyFitEx

PolyFitEx

Advanced Analysis Library Only

AnalysisLibErrType PolyFitEx (double arrayX[], double arrayY[], ssize_t numberOfElements, int order, int specCoefficientOrder[], double specCoefficients[], int numberOfSpecCoefficients, int algorithm, double fittedData[], double coefficients[], double *mse);

Purpose

Fits the data set (x, y) to a polynomial model using the Least Square method. The following equation represents the polynomial model:

where a0, a1, ... , am-1 are the polynomial coefficients.

Parameters

Input
Name Type Description
arrayX double [] The x value of the data set (x, y). If fittedData is NULL, the best fit array overwrites arrayX.
arrayY double [] The y value of the data set (x, y).
numberOfElements ssize_t The length of arrayX and arrayY.
order int The order of the polynomial used in the polynomial fit operation. Polynomial order must be greater than or equal to 0. If the polynomial order is less than zero, this function sets the coefficients parameter to an empty array and returns an error. In real applications, polynomial order is less than 10. If the polynomial order is greater than 25, the function sets the coefficients beyond order 25 in the coefficients parameter to zero and returns a warning.
specCoefficientOrder int [] The orders on which the polynomial coefficients are constrained to be the known values specified in specCoefficients. Set specCoefficientOrder to NULL if there are no constrained coefficients.
specCoefficients double [] The coefficients on the orders specified in specCoefficientOrder. Set specCoefficients to NULL if there are no constrained coefficients.
numberOfSpecCoefficients int The length of specCoefficientOrder and specCoefficients. numberOfSpecCoefficients is optional. Set numberOfSpecCoefficients to 0 if a specified order and coefficients are not available.
algorithm int The algorithm used to solve the linear equations in polynomial fit. algorithm must be one of the following values. NI recommends that you use POLYFIT_SVD for numerical stability.
  • ALGORITHM_POLYFIT_SVD (0)—Use Singular Value Decomposition to solve the linear equations in polynomial fit.
  • ALGORITHM_POLYFIT_QR (1)—Use QR Decomposition to solve the linear equations in polynomial fit.
  • ALGORITHM_POLYFIT_LU (2)—Use LU Decomposition to solve the linear equations in polynomial fit.
  • ALGORITHM_POLYFIT_CHOLESKY (3)—Use Cholesky Decomposition to solve the linear equations in polynomial fit.
Output
Name Type Description
fittedData double [] The y values calculated using the polynomial model. If fittedData is NULL, the best fit array overwrites arrayX.
coefficients double [] The coefficients of the fitted polynomial in ascending order of power.
MSE double The mean square error.

Return Value

Name Type Description
status AnalysisLibErrType A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants.

Additional Information

Library: Advanced Analysis Library

Include file: analysis.h

LabWindows/CVI compatibility: LabWindows/CVI 8.0 and later

Was this information helpful?