Company Events Academic Community Support Solutions Products & Services Contact NI MyNI

fit (MathScript RT Module Function)

LabVIEW 2012 MathScript RT Module Help

Edition Date: June 2012

Part Number: 373123C-01

»View Product Info
Download Help (Windows Only)

Owning Class: approximation

Requires: MathScript RT Module

Syntax

coefs = fit(xdata, ydata, model)

[coefs, bestfit] = fit(xdata, ydata, model)

[coefs, bestfit, residue] = fit(xdata, ydata, model)

Description

Computes the coefficients for a curve fitting model.

Examples

Inputs

Name Description
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.

'exp1' Specifies an exponential fit.
'linear' Specifies a linear fit.
'polyn' Specifies a polynomial fit of order n.
'power1' Specifies a power fit.

Outputs

Name Description
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.

Details

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

Examples

XDATA = 1:0.1:10;
YDATA = 1.532*XDATA.^3-0.001*XDATA.^2+4*XDATA-1;
COEFS = fit(XDATA, YDATA, 'poly3');


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit