取消
显示结果 
搜索替代 
您的意思是: 

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?

0 项奖励
1 条消息(共 7 条)
3,510 次查看
解答
接受人 gtathatos

Hi gstathatos,

 

here's a suggestion:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
2 条消息(共 7 条)
3,504 次查看

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 项奖励
3 条消息(共 7 条)
3,497 次查看

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 项奖励
4 条消息(共 7 条)
3,495 次查看

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
5 条消息(共 7 条)
3,489 次查看

Hi Gerd,

 

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

0 项奖励
6 条消息(共 7 条)
3,487 次查看

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 项奖励
7 条消息(共 7 条)
3,475 次查看