LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Averaging the rows in a 1D array as samples are taken

I am continuous taking 10 samples of voltage every second and therefore the output (Y) every second is  an array of one column and 10 rows.  How do I create loop that will average the rows of each sample taken.  For example, after 8  seconds I will have 8 arrays--from these array I want to average the 8 values in the 1st row of each array. Ultimately I want to ouput a 10 row array where each row is a mean value.

 

I'm new at programming and Labview so thanks in advance!

0 Kudos
Message 1 of 6
(3,190 Views)

Just sum the size=10 arrays in a shift register and divide by the number of iterations for display.

 

Here's an example:

 

Message Edited by altenbach on 07-10-2009 09:48 AM
0 Kudos
Message 2 of 6
(3,183 Views)
Thanks! But how do I know that its averaging the rows and not the columns?
0 Kudos
Message 3 of 6
(3,170 Views)

1D arrays in LabVIEW are just that. Unlike some other programming languages, there is no such thing as a "row" or "column" 1D array.

 

Even if you have a 2D 1xN or Nx1 array, the shift register would just accumulate a 2D array, and it would keep adding to it, while keeping the dimension the same. (The add operates element wise).

It would be much easier for us if you could show is some code so we can see your exact data structures.
Message Edited by altenbach on 07-10-2009 11:33 AM
0 Kudos
Message 4 of 6
(3,150 Views)

Sure, I've uploaded the code I have so far (still a work in progress..).  I added in the shift register--is this the correct way that I want  to this?

0 Kudos
Message 5 of 6
(3,141 Views)

For your code, you have a 1D array, so why would you built it into a 2D array. Makes no sense. 😉

 

Here's a quick draft on how to average your Y array. Use the while loop for the shift register.

 

You also don't need the big sequence structure. Dataflow fully determines execution order. 😉
Message Edited by altenbach on 07-10-2009 01:07 PM
0 Kudos
Message 6 of 6
(3,121 Views)