LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I am trying to get the average of every 10 points in my table...

Solved!
Go to solution

I have a table of data and would like to get an output of the average every 10 points. For example, the average of points 1-10, then the average of points 11-20, then 21-30, etc.

 

The challenge is that I do not know ahead of time how many points the sensor will collect each run because it depends on some external factor. I have attached a picture with some made-up data to illustrate what my table looks like. In the example I attached, the averages would be (11+34+125+77+44+232+25+213+22+89)/10 and (90+45+77+26+1+22+57+67+360+33)/10.

 

My initial attempt used a case structure which found a running average and then reset whenever a multiple of 10 was reached. However, this method does not seem very efficient. Does anyone have any better ideas?

0 Kudos
Message 1 of 5
(5,493 Views)

I use a function in Signal Processing >> Pt By Pt >> Prob. and Stat >> Mean.vi

 

You enter the number of items you want to calculate and as you add them one by one, the VI outputs a running average for the last N elements. 

aputman
Message 2 of 5
(5,491 Views)

Like aputman said you could use the idea of signal processing pt by pt OR

 

You could write a simple looping function and a shift register to accomplish your task. You browse through your elements (10 elements), use array subset, make an average and loop it through.


Kudos are the best way to say thanks 🙂
0 Kudos
Message 3 of 5
(5,468 Views)

How about this? Use Delete array subset to extract chunks for averaging, and a shift register to retain the remaining array.

Best regards,

Jarle Ekanger, MSc, PhD, CLD
Flow Design Bureau AS

- "The resistance of wires in LabVIEW is not dependent on their length."
Message 4 of 5
(5,456 Views)
Solution
Accepted by topic author Laura121

@JarleEkanger wrote:

How about this? Use Delete array subset to extract chunks for averaging, and a shift register to retain the remaining array.


It is typically not advisable to use "delete from array" in a tight loop. The constant memory reallocations due to array resizing are probably inefficient.

 

Here's one simple way to do it..

(If the number of points is not divisible by 10, the excess tail is discarded. You can easily modify that behavior if desired.)

 

 

 

Download All
Message 5 of 5
(5,425 Views)