Example Code

DownSampling and Averaging of a 2D Array

Code and Documents

Attachment

Working in the Lab, we often want to sample channels at a very high rate, however sometimes, whether it be to reduce the file size or smooth out noise on the channels, we would like to average the data.

I created a simple VI that takes as its input a 2D array and an integer.

The VI takes the input array and averages N samples on each row of Data and ouputs the values into a new 2D Array.

Currently my data is saved where each channel occupies a row. With a small amount of rework (transposing the input array) this VI could work in instances where each channel occupies a column instead.

The output array has a number of columns equal to the number of input columns divided by N, where each new value is an average of N old values.

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

Contributors