From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Interpolate Data for NaN Array Values in LabVIEW

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 VI takes an Array with NaN (not a Number) values and interpolates new values to fill in for the NaN data.

This VI is designed to work with data with a constant delta X value and this algorithm will not work for generating the first or last data point in an array. This example is useful because interpolates new values from an Array with NaN values.

 

Description

Use For the iterates every Array Value then the Index Array is looking for NaN Values. The While Loop continues iterate through the array until you find valid data (looks for long chains of NaN). After that a For Loop generates the Missing Values (last known value + step size*(i+1)) and finally the Array Subset replace the NaN Value.

 

Requirements

LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code
1. Y in Array Control is a predefined Array that does have some NaN values
2. Run VI
3. Y Repaired Indicator Array will show interpolate values where NaN values were in Y in Array

 

Additional Information or References

Snippet 5504.png

 

 

 

 

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

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