Company Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI

fit (MathScript Function) (Windows, Not in Base Package)

LabVIEW 8.5 Help
August 2007

NI Part Number:
371361D-01

»View Product Info

Member of the approximation class.

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.

Examples

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


Resources


 

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