LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

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

Solved!
Go to solution

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?

0 Kudos
Message 1 of 7
(2,932 Views)
Solution
Accepted by topic author gtathatos

Hi gstathatos,

 

here's a suggestion:

check.png

Best regards,
GerdW


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

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
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 7
(2,919 Views)

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.
0 Kudos
Message 4 of 7
(2,917 Views)

A slightly modified version of GredW's code.

 

Average26Elements.png

 

(I always like to play with array :))

-----

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

Hi Gerd,

 

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

0 Kudos
Message 6 of 7
(2,909 Views)

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
0 Kudos
Message 7 of 7
(2,897 Views)