Search code examples
arrayslabview

Labview: How do I build an array of many copies of the same value?


I'm using a MEAN function from the Prob and Stats function palette in one of my subVIs to attempt to counteract aliasing from a speed sensor.

I tried a butterworth filter, but it needs about 2000 samples at 2kHz to properly correct the aliasing, and that causes an instrumentation delay.

The problem is, the MEAN function takes a 1D array of about 800 elements and gives the mean. I need to return it to a 1D array of 800 elements to be able to record and act on that data. I'm fairly certain that the "build Array" function only inserts the data into the array 1 element at a time though.

Is there any faster way to build a 1D array of 800 elements from the output of that MEAN function, or do I have to expand the "Build Array" funtion into a SubVI and copy it 800 times? Thanks!!!

enter image description here


Solution

  • Use Initialize Array.vi from the Array palette.

    Wire the output from Mean.vi to the element terminal. Use the Array Size.vi on the original array and wire it to dimension size 0. This will guarantee that the resulting array will always match the original's size, in case you change your DAQ configuration.

    Initialize Array.vi