Example Code

Unique Random Integer Generator

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 is aimed to generate a list of unique random integers. (No more than one of any integer occurs in the list)

 

Description

The purpose of this VI is to generate a list of unique random integers. No more than one of any integer occurs in the list.

This VI takes the number of unique integers you request as well as the numeric range allowable for each integer.  If this number of unique values exceeds the range then this VI will run forever until hard-stopped in LabVIEW.

 

Requirements

  • LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

  1. Input the values of Number of Unique Values and Range.
  2. Run the VI and List of Unique Random Numbers will show the result.
  3. If Number of Unique Values exceeds Range, then this VI will run forever until hard-stopped in LabVIEW.

 

Additional Information or References

VI Snippet

1.png

 

 

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

Sincerely,

Greg S.

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