From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

# 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,672 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,666 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

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Message 3 of 7
(2,659 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,657 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,651 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,649 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,637 Views)