Example Code

Create Sub-Array Based on Threshold 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 example VI creates a Sub-Array based on whether or not values are above or below a threshold.

 
Description
10 random doubles are generated and then compared to a user-defined threshold. The user picks if the values must be above or below. Then a sub-array is built based on wether or not the values are above or below the threshold, based on user input. Shift reigsters are used to store the sub-array as it builds. Before the first loop, the array is initialized. The array either stays the same or adds a new value as the loop iterates.

 
Requirements

  • LabVIEW 2012 (or compatible)


Steps to Implement or Execute Code

  1. Set a threshold.
  2. Select whether the values should be above or below. If 'Above?' is True, then the program selects values that are above the threshold. If 'Above?' is False, then the program selects values below the threshold.
  3. Click 'Run'. Random numbers will be generated and a new sub-array built from those random values based on the threshold value.

 

Additional Information or References
VI Block Diagram

1.png 

 

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

 

Taylor B.
National Instruments

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