LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Averaging Elements in an Array

Let's say I have a one-dimensional array with 100 elements. I need to
average the 3rd through 97th elements. How would I do this?

Jeff
0 Kudos
Message 1 of 5
(3,247 Views)
Use the Array Subset function with index 3 and length (97-3)+1. Then use the Mean function (in Analyze...Mathematics...Probability & Statistics) on the resultant array.
==============================================

Message 2 of 5
(3,247 Views)
Length not required. It defaults to all.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 5
(3,247 Views)
> Let's say I have a one-dimensional array with 100 elements. I need to
> average the 3rd through 97th elements. How would I do this?
>

There are a couple ways. You could use array subset to extract and send
to the Average VI in the analysis palette. Actually, it is named as
Mean.vi, and is most easily found using the Search button on the palettes.

You could also do your own Sum and divide by elements if you like. If
working on very large datasets, you may choose to loop through rather
than extracting the subArray. This will work inplace and not need to
make a copy of the array. If you want to average a very large array
except for a small number, you could also do the overall average of the
array and then subtract the average of the element
s you don't want.

Greg McKaskle
Message 4 of 5
(3,247 Views)
Jeff,

Keep in mind that the first element in the array is indexed as 'element 0.' That's the standard LabVIEW array formatting, so be careful with your array syntax. If you had the following array: [a b c d], letter 'b' is element 1.

I hope this helps.

Kind Regards,

Joe Des Rosier
National Instruments
0 Kudos
Message 5 of 5
(3,247 Views)