Example Code

Count Values in an Array

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 demonstrates a simple technique for counting the occurrences of integer numbers in an array.

 

Description

This VI demonstrates a simple technique for counting the occurrences of integer numbers in an array, the output array will show the integer number at corresponding index.

 

2.png

 

For example, if the input array is [2, 5, 3], then the size of output array will be 5+1=6, and output array will be [0, 0, 1, 1, 0,1]. 

 

Requirements

  • LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

  1. Input the integer value into the Input Array.
  2. Run the VI.
  3. The Value Counts will count the occurrences of integer number and display them at the corresponding index.

 

Additional Information or References

VI Snippet

1.png 

 

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

Applications Engineer
National Instruments

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