Example Code

Find Minimum Value in Array, Remove it, Average Remaining 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 example demonstrates two methods of searching an array of values for the minimum value. Then removing the minimum value from the array and averaging the remaining values.

 

Description

The Find Lowest Value in Array Take Average VI performs the following steps:

  1. The VI searches the array for the minimum value and the index of that minimum value.
  2. Deletes the minimum value element from the array and calculates the number of elements in the array. 
  3. The VI then divides the resultant array by the number of elements.

 

The Find Lowest Value in Array Take Average Modified VI performs the following steps:

  1. The VI searches the array for the minimum value, adds all the values of the array together, and calculates the number of elements in the array. 
  2. The VI then subtracts the minimum value from the sum of the array and divides this result by the number of elements in the array minus one.

  

Steps to Implement or Execute Code

  1. Download and open the original or modified example
  2. Initialize the array with the values you wish to search or use it as a SubVI
  3. Run the VI and see the average value

  

Requirements to Run

Software

LabVIEW 8.6 or 2012 or compatible 

 

Additional Images

 

Block Diagram of Find Lowest Value in Array Take Average

Find Lowest Value in Array Take Average_LV86.png

 

 

  Block Diagram of Find Lowest Value in Array Take Average Modified

 

Find Lowest Value in Array Take Average_LV86.png

 

 

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

Will
CLA, CLED, CTD, CPI
LabVIEW Champion
Choose Movement Consulting
choose-mc.com

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

Comments
Todd S.
NI Employee (retired)
on

Thanks for posting!

Todd S.
LabVIEW Community Manager
National Instruments
GregSands
Active Participant
Active Participant
on

I wonder if you know that the entire left-hand side of the VI (up to and including "Search 1D Array") could be replaced by the single function "Array Max & Min" found in the array palette, which returns not only the minimum, but its index as well.

Todd S.
NI Employee (retired)
on

I was thinking the same thing when I left my comment, but was too afraid to say...

Todd S.
LabVIEW Community Manager
National Instruments
rpursley8
Active Participant
Active Participant
on

See attached.  I runs 4-5 times faster on large arrays.

Randall Pursley
Todd S.
NI Employee (retired)
on

BOOM!  Nice work!

Todd S.
LabVIEW Community Manager
National Instruments
Will_S.
Active Participant Active Participant
Active Participant
on

I have no idea how I missed that function....oh well, thanks for the tip!

Will
CLA, CLED, CTD, CPI
LabVIEW Champion
Choose Movement Consulting
choose-mc.com