LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a moving average

Hi,
I have a measurement system giving me data every 100 ms. Now I want to have
a moving average of 10 values because the values are varying a lot.
How can I do this?

By the way, I am using LabView 6.1.
Greetings,

ErX.
0 Kudos
Message 1 of 3
(3,324 Views)
You can use Waveform Chart with history length=10.
Data that you get insert to this chart and make averaging of 10 values that it collect.
You can make the chart not visible.
Message 2 of 3
(3,324 Views)
Hi ErX,
I assume that you're collecting the data during a loop of some kind. The easiest way to do a moving average (I assume you're refering to effectively running a window over the data) is to take the array of data you've collected so far, and using the loop index, get a 10 element long array from this, starting 10 elements back from where you were. You can then sum the array elements and divide by 10. Since this happens each time in a loop, your memory useage would not be optimal, because the 10 element memory space would keep being created and destroyed.
A bit better is to create a 10 element long shift register, that you fill in as you go, manipulating the data within this one memory space (use the rotate 1D array to shift the data back by one element)
, and then insert (replace) the new data point at the last element. This should be a better implementation from a memory point of view, but I don't know about speed (guess it's hardware dependant as usual if it's a problem).
Hope that helps

(example below)

S.
// it takes almost no time to rate an answer Smiley Wink
Message 3 of 3
(3,324 Views)