From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

calculating the average

I'm trying to use LabView to calculate the running average of a counter hooked up through the GPIB interface. The counter collects the data into an array and I tried to output this using the Write LabView VI, and then using the Read LabView VI to add the data together, and then writing the added result to another file. After collecting three sets of data, however, I find that LabView is adding the 1st set to the 2nd set, but then adding the 1st set to the 3rd set. I would like it to add the 1st set to the 2nd set, and the result of that to the 3rd set...like a running average. Any help would be greatly appreciated. Thanks.
0 Kudos
Message 1 of 2
(2,814 Views)
Hi John,

There are different ways of performing running average. One of the easiest is to add the value from the last couple of measurements and divide it with the number of measurements. You could use a Shift Register in a loop to keep the value of the last couple of measurements instead of saving everything to a file first.

What you are explaining, is actually the average of the total number of measurements. Doing this you would have to apply weighting to the previous average, so it has a higher importance if it represents a lot of data compared to only a few measurements.

You can find both types of averaging in the attached "Average.vi" and "Average.jpg" (in case you don't have LabVIEW 7.1).

Best regards,
Philip C.
National Instrument
s
- Philip Courtois, Thinkbot Solutions

Thinkbot Solutions
Download All
Message 2 of 2
(2,814 Views)