LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Exclusion of values in mean calculation

Hello...

I have a problem with mean calculation.  I need to create a VI that by means of a Boolean (true or false) I can choose which value will be used for mean calculation. I used the Select function to do this but when I push the button to say "Don't use this number in mean calculation", the Select function does not allow that the number go to the Mean function but the Select funcion sends a Zero. The result of is that the mean value is wrong, because the number does not goes to the Mean calculation, but the function consider it like zero.

In my example attached I used:

Situation without select control: (2+4+6)/3 = 4

Situation with select control (4+6)/3 = 3.33 (its wrong, the correct should be (4+6)/2 = 5, because I excluded the value 2.

My main problem is: how to insert a Null value, not zero. Another question, the Select function is the only way to "Switch" the pass of values to other functions? This question is also related to "Case Structure" , because, for example, when the value is False, I don't want to send a zero forward, I want to send nothing!

In my example, when button is pushed, the value must be excluded.

Thank you very much

Daniel
0 Kudos
Message 1 of 18
(3,759 Views)

Hi Daniel,

the calculation is correct, because the array size is 3. Change the code in the way, that only the numbers you want are in the array. See the attached picture.

Mike



Message Edited by MikeS81 on 05-01-2008 08:53 AM
0 Kudos
Message 2 of 18
(3,757 Views)

Hi Daniel,

if you want to decide it for every number, here is another example.

Mike

0 Kudos
Message 3 of 18
(3,751 Views)
Thanks for attention Mike....

Your solution will solve my problem but will be hard to build because I used in the example only 3 values, but I use over than 50 values in real! I will need to create the same number of Structures.

Is there any way to return a Null value, instead of Zero? Because if there is, I will need to build a large number of Select function, instead of a lot of structures. Its better because they are smaller on the block diagram.

Thanks

Daniel
0 Kudos
Message 4 of 18
(3,749 Views)

Hi Daniel,

if you want to decide it for every number, here is another example.

Mike




Sorry, I did not see this message and sent another message to you. I think that the idea in your second message will answer my second question.



Thanks



Daniel


0 Kudos
Message 5 of 18
(3,743 Views)
Mike...

I still have one question... Sometimes I need a function that acts like a "Wire Cutter". A function to blockade the pass of a vaue. The only way that I know to do this simple task is by means of Select function, but this function does not return a Null value, the function returns a Zero. What I should wire to the Select function to acts as a Null value?

Thanks for attention... I am a begginer user

Daniel
0 Kudos
Message 6 of 18
(3,728 Views)

Hi Daniel,

there is no "wire cutter". Can you show an example of what you want?

Mike

0 Kudos
Message 7 of 18
(3,710 Views)


daniel.penteado wrote:
I still have one question... Sometimes I need a function that acts like a "Wire Cutter". A function to blockade the pass of a vaue. The only way that I know to do this simple task is by means of Select function, but this function does not return a Null value, the function returns a Zero. What I should wire to the Select function to acts as a Null value?


An integer is always an integer, there is no "null value". Scanning an empty string just returns the default value, zero in this case.
(With DBL, you have a few more options, such as NaN).
 
 
You could use an array with one element and substitute an array with zero elements under some conditions, but this seems like an unecessary hack (see picture).


Message Edited by altenbach on 05-01-2008 12:51 AM
0 Kudos
Message 8 of 18
(3,707 Views)
Could you explain why you want some values to disappear in the mean calculation? Are there some rules as to which values are to be included or excluded from the calculation.

I ask this so people may help you see you problem in a different light and come up with a solution different to the one you come up with.
Regards,
André (CLA, CLED)
0 Kudos
Message 9 of 18
(3,676 Views)
If you can restructure your input, something like this would also work


Message Edited by JeffOverton on 05-01-2008 12:18 PM
Download All
0 Kudos
Message 10 of 18
(3,659 Views)