LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I need help to calculate the average of the first 100 measurements of each element of 2D array

Please I need help to calculate the average of the first 100 measurements of each element of 2D array. I'm making measurements with an instrument that gives me back a 2D under Labview, it has 4 channels and supports up to 25 sensors per channel. I need to get the average of the first 100 measurements of each sensor, each row of the array is a measurement channel and each column a sensor. Attached file data acquisition.

0 Kudos
Message 1 of 7
(2,970 Views)

Hi Redney,

 

If I understand your question I have a solution to propose: Wire the 2D DBL to a shift register on your loop - just add every new Array to the previous ones. After 100 iterations divide the array by 100 - the elements of the array in the shift register now contain the average of those 100 iterations.

 

I just realized the array is nested too deeply to comfortably use a shift register. Use a feedback node instead.

 

Let us know if this isn't what you want do.

0 Kudos
Message 2 of 7
(2,958 Views)

I do not understand, to access each array element 2D i need two loops For, one to scroll through the rows and another to scroll the columns. I do not understand that I take the loop count and how, can be illustrated by an example. Thank you for your help.

0 Kudos
Message 3 of 7
(2,956 Views)

Hi,

 

I've created an example of your code with the modification I think you need (I may be misunderstanding you).

"WavelengthAverage" contains the average of all recent measurements.

 

There are sub vis missing, that you didn't include in your post.

 

0 Kudos
Message 4 of 7
(2,952 Views)

I can see how to implement the average, so I see no guarantee that it is where the first 100 values

0 Kudos
Message 5 of 7
(2,947 Views)

I just need to get the average of the first 100 measurements of each sensor, and run this operation once.

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

Right, my example didn't contain any means to make sure this is the average of a hundred iterations. It doesn't even necessarily calculate the correct average since the measurement doesn't have to be executed during each iteration of the while loop. You should replace my wiring to the iteration counter with another feedback node, counting only the measurements actually performed, to obtain the correct divisor. To check whether the desired amount of measurements has been averaged wire the divisor to a case structure. That structure should have a case for "100" - performing the actions you want (perhaps stopping the loop?) and a catch all else case, that does nothing.

 

I hope this helps

Florian

0 Kudos
Message 7 of 7
(2,943 Views)