Example Code

Extrapolating Linear Best Fit

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Overview 

This is an example using a Temperature vs Pressure Graph using the ExtrapXLinearBestFit SubVI. The VI reports the X Intercept and the Slope and outputs an array of (X,Y) coordinates for plotting on a graph.

 

Description

The 'Linear Best Fit' VI included with LabVIEW doesn't extrapolate back to the X axis.  This is a very simple idea of how to do so.

The SubVI extends a linear line of best fit back to the X axis as well as extending beyond the end of the data so that you can place it on top of your existing curve on a graph.

 

Requirements

  • LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

  1.  Run the VI.
  2. Get the Slope and Absolute Zero plotting on the graph.

 

Additional Information or References 

VI Snippet

162.png

**This document has been updated to meet the current required format for the NI Code Exchange.**

 

Oli
LabVIEW Student Ambassador
National Instruments UK

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
harisiam
Member
Member
on

hey, oli.. i think this will not work..

Never send a human to do a machine's job.
Oli.P
NI Employee (retired)
on

Any particular reason?

Oli
LabVIEW Student Ambassador
National Instruments UK
harisiam
Member
Member
on

no particular reason i cant tell.. i was also working on the tangential fit to a curve,.. i got it.. nd its somewhat huge code..this one i tried.. but not working with my graph..

Never send a human to do a machine's job.
Oli.P
NI Employee (retired)
on

It should work fine, it's just an extension of the existing LabVIEW Linear Best Fit VI.  The inputs X and Y are your curve data, then the outputs Extrapolated X and Y are a line of best fit extended to the X axis and slightly beyond your original curve.  It works for me.  I've added an example of how it could be used.

Oli
LabVIEW Student Ambassador
National Instruments UK