Calculate the Sum of Each Row or Column in an Array

Updated Jan 8, 2018

Reported In

Software

  • LabVIEW Base
  • LabVIEW Full
  • LabVIEW Professional

Issue Details

In the case of a 2D array of any size, how can I add the rows or the columns together in to a 1D array?

Solution

A row or a column of a 2D array is also a 1D array. In LabVIEW you can use the Add Array Elements function form the Numeric Palette to calculate the sum of a 1D array. Use this function in a For Loop and connect the input array and also the output array with Auto-Indexed Tunnels.
 
  • If you need to calculate the sum of the rows you need to connect the array to the For Loop directly:
 
  • If you need to calculate the sum of the columns you need to connect the array to the For Loop through the Transpose 2D Array function:
  

WAS THIS ARTICLE HELPFUL?

Not Helpful