# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## How to take an average every 26 samples in an array of 219 elements?

Hello to every one,

Well the problem i have is that i am having an array of 219 elements and every 26 elements i want to take an average.Can please someone suggest a code solution for that?

Message 1 of 7
(2,134 Views)
Solution
Accepted by topic author gtathatos

## Re: How to take an average every 26 samples in an array of 219 elements?

Hi gstathatos,

here's a suggestion:

Best regards,
GerdW

using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 7
(2,128 Views)

## Re: How to take an average every 26 samples in an array of 219 elements?

Asuming you want the average of the 26 sample sets you need to wire the Length in Gerds example also.

/Y

"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Message 3 of 7
(2,121 Views)

## Re: How to take an average every 26 samples in an array of 219 elements?

Gerd,

while your suggestion is really good (scalable, well written), you are missing imho one wire: The length of each "chunk" should most probable be 26!

@gstathatos:

Another question which comes to my mind is:

Gerds suggestion chunks the array , so you will get 219/26 = 8 chunks. Each chunk should most probable suffix to the the previous one without having overlapping. Please verify this.

The other option would be to have a "moving average".

hope this helps,

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 4 of 7
(2,119 Views)

## Re: How to take an average every 26 samples in an array of 219 elements?

A slightly modified version of GredW's code.

(I always like to play with array :))

-----

The best solution is the one you find it by yourself
Message 5 of 7
(2,113 Views)

## Re: How to take an average every 26 samples in an array of 219 elements?

Hi Gerd,

Your suggestion code work as i expected and many thakns for that.

Message 6 of 7
(2,111 Views)

## Re: How to take an average every 26 samples in an array of 219 elements?

Hi to all,

yes, I forgot to wire the "Length" input of the ArraySubset function. But this was noticed easily...

@P Anand:

Using DeleteFromArray is forcing shuffling of the array content. Using ArraySubset should be more memory-efficient (and probably faster for big arrays).

Best regards,
GerdW

using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 7
(2,099 Views)