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

Introduction to Curve Fitting

LabVIEW 8.5 Help
August 2007

NI Part Number:
371361D-01

»View Product Info

You can use the Fitting VIs to perform curve fitting analysis or regression.

The least squares method of curve fitting fits a curve to a particular data set. Equation A defines the least square error.

e(a) = [f(x, a) – y(x)]2 (A)

where e(a) is the least square error, y(x) is the observed data set, f(x, a) is the functional description of the data set, and a is the set of curve coefficients that best describes the curve.

For example, if a = {a 0, a 1}, the following equation yields the functional description:

f(x, a) = a 0 + a 1 x (B)

The least squares algorithm finds a by solving the system defined by Equation C.

(C)

To solve the system defined by Equation C, you set up and solve the Jacobian system generated by expanding Equation C. After you solve the system for a, you can use the functional description f(x, a) to obtain an estimate of the observed data set for any value of x.

The Fitting VIs automatically set up and solve the Jacobian system and return the set of coefficients that best describes the data set. You can concentrate on the functional description of the data without having to solve the system in Equation C.

Note  You can use the Fitting VIs only in the LabVIEW Full and Professional Development Systems.

Applications of Curve Fitting

In some applications, parameters such as humidity, temperature, and pressure can affect data you collect. You can model the statistical data by performing regression analysis and gain insight into the parameters that affect the data.

The following figure shows the block diagram of a VI that uses the Linear Fit VI to fit a line to a set of data points.

You can modify the block diagram to fit exponential and polynomial curves by replacing the Linear Fit VI with the Exponential Fit VI or the General Polynomial Fit VI.

The following figure shows a multiplot graph of the result of fitting a line to a noisy data set.

The practical applications of curve fitting include the following applications:

  • Removing measurement noise
  • Filling in missing data points, such as when one or more measurements are missing or improperly recorded
  • Interpolating, which is estimating data between data points, such as if the time between measurements is not small enough
  • Extrapolating, which is estimating data beyond data points, such as looking for data values before or after a measurement
  • Differentiating digital data, such as finding the derivative of the data points by modeling the discrete data with a polynomial and differentiating the resulting polynomial equation
  • Integrating digital data, such as finding the area under a curve when you have only the discrete points of the curve
  • Obtaining the trajectory of an object based on discrete measurements of its velocity, which is the first derivative, or acceleration, which is the second derivative

Resources


 

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