12-01-2011 04:51 AM
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.
12-01-2011 06:51 AM
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.
12-01-2011 07:11 AM
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.
12-01-2011 07:19 AM
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.
12-01-2011 07:27 AM
I can see how to implement the average, so I see no guarantee that it is where the first 100 values
12-01-2011 07:36 AM
I just need to get the average of the first 100 measurements of each sensor, and run this operation once.
12-01-2011 07:41 AM
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