How Can I Calculate the Mean of a 2D Array?

Updated Jul 2, 2020

Reported In


  • LabVIEW

Issue Details

I would like to calculate the mean of all elements in a 2D array. I tried to use, but it seems to only accepts a 1D array as its input. Is there a function that would do the same for a 2D array?


Unfortunately, there is not a function that is designed to calculate the mean of a whole 2D array by itself. Therefore, you would need to come up with your own algorithm for that. Below is one way of doing it.
  1. Calculate the sum the 2D array by using Add Array
  2. Calculate the size of the 2D array by using Array, which returns the number of elements of each dimension in 1D array
  3. Calculate the total number of elements in the 2D by multiplying the elements, calculated at Step 2., by using Multiply Array
  4. Divide the output of Add Array by that of Multiply Array
This technique can extend to 3D arrays and greater dimensions.