Owning Class: approximation
Requires: MathScript RT Module
coefs = fit(xdata, ydata, model)
[coefs, bestfit] = fit(xdata, ydata, model)
[coefs, bestfit, residue] = fit(xdata, ydata, model)
Computes the coefficients for a curve fitting model.
|xdata||Specifies the independent values. xdata is a real, double-precision vector.|
|ydata||Specifies the dependent values. ydata is a real, double-precision vector.|
|model||Specifies the fitting model. model is a string that accepts the following values.
|coefs||Returns the coefficients of the fit for a model. If model is polyn, coefs returns the coefficients in decreasing order of power. If model is linear, coefs returns the slope and intercept of the linear fit. If model is exp1, coefs returns the amplitude and damping of the exponential fit. If model is power1, coefs returns the power and amplitude of the power fit. coefs is a real, double-precision vector.|
|bestfit||Returns the values of the fitted curve evaluated at the points in xdata. bestfit is a real, double-precision vector.|
|residue||Returns the residue of the fitted curve. residue is a real, double-precision scalar.|
The following table lists the support characteristics of this function.
|Supported in the LabVIEW Run-Time Engine||Yes|
|Supported on RT targets||Yes|
|Suitable for bounded execution times on RT||Not characterized|
XDATA = 1:0.1:10;
YDATA = 1.532*XDATA.^3-0.001*XDATA.^2+4*XDATA-1;
COEFS = fit(XDATA, YDATA, 'poly3');