LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Mean-row of 2D array?

Hello,

[LabView 6.0.2]
There's a VI a miss in LabView, but perhaps I just didn't find it:

I'm getting back a 2D array outside of a For-loop; the size of each
dimension is not known explicitly in advance.
I would like to calculate the mean-row of the array (Sum of rows /
number of rows).
It's not difficult, but I did not found any standard VI performing that!
Does it exist? The method I use instead is just another For-loop, but I
would be surprised if it has not been foreseen by the implementors.

Thanks in advance,

Pierre Chatelier
0 Kudos
Message 1 of 3
(2,774 Views)
I don't think there is a built-in function that explicitly does what you are asking for, but you shouldn't need a seperate for loop to do the processing.

I assume that because the 2D loop is coming from a FOR loop that there is probibly something (acquisition routine?) inside the loop that is generating a 1D array (the rows in your output). This 1D array is then accumulated into a 2D array at the border of the FOR loop.

If this is so, all you have to do is sum the elements of each 1D array inside the loop and divide the result by the N value for the loop. You can then do whatever you need to do to return the calculated results in the desired form.

In general look for times in which you have two consecutive FOR loops that are executing the same number of
times. Very often you can simplify the code by consolidating the functions into a single loop.

If you post your code (in V6.0 format) I'll look at it for you and show you what I mean.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 3
(2,774 Views)
> I don't think there is a built-in function that explicitly does what
> you are asking for, but you shouldn't need a seperate for loop to do
> the processing.
>
> I assume that because the 2D loop is coming from a FOR loop that there
> is probibly something (acquisition routine?) inside the loop that is
> generating a 1D array (the rows in your output). This 1D array is then
> accumulated into a 2D array at the border of the FOR loop.
>
> If this is so, all you have to do is sum the elements of each 1D array
> inside the loop and divide the result by the N value for the loop. You
> can then do whatever you need to do to return the calculated results
> in the desired form.
>
> In general look for times in which you have two consecutive FOR loops
> t
hat are executing the same number of times. Very often you can
> simplify the code by consolidating the functions into a single loop.
>
> If you post your code (in V6.0 format) I'll look at it for you and
> show you what I mean.

Thank you very much!
I understand very well what you mean, but I didn't want to do this way,
because I prefer to calculate the mean after the loop. The program I'm
coding is for somebody else, so I try to make it the easiest to understand
and "follow".
After that, which is the simplest way...? It's a little subjective.
Bah, that's ok.
Thanks for all!
0 Kudos
Message 3 of 3
(2,774 Views)