LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to calculate mean of 1D array?

Solved!
Go to solution

Could someone please help me, how could I calculate mean of 1D array? For example, if the 1D-array is [2, 3], I would get mean = 2,5. Thank you very much!

Message 1 of 8
(28,384 Views)
Solution
Accepted by topic author framboise1

Use the mean function. You can use the search or quick drop to look for it in case you don't know where to find it.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 2 of 8
(28,373 Views)

Thank you for your answer! For some reason, the mean function doesn't work properly. Could you please check in the picture, where the problem could be? 


 

0 Kudos
Message 3 of 8
(28,368 Views)
Solution
Accepted by topic author framboise1

remove the FOR loop on trhe right. It does not belong there.

Message 4 of 8
(28,356 Views)

Thank you for your answer! If I remove the FOR loop, for some reason it gives me NaN output. Input is 1D array and it looks as it should ([1, 2, 3, 2, 1, etc.]).

0 Kudos
Message 5 of 8
(28,351 Views)

Please post your VI. The image is not sufficient to understand what you are looking for.

NaN is "not a number" which means that you have invalid elements.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 6 of 8
(28,335 Views)

So assuming you are beginner in LabVIEW,

-Create New VI

-Place array constant/ Control and keep numeric constant inside it.

-Now enter 2 and 3 in array

-And then use mean vi: http://zone.ni.com/reference/en-XX/help/371361M-01/gmath/mean/#parent

-Now if your mean output is not 2.5 then mean function is not working correctly ok?

-If the array is empty also you would get NaN.

Thanks
uday
Message 7 of 8
(28,322 Views)

Thank you very much for your help! I found the problem (as you said, it was in the input) and now the mean function works properly! 🙂

0 Kudos
Message 8 of 8
(28,308 Views)