LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Friday grumpiness: mode.vi

Chaos,

As it turns out, the unique numbers and multiplicity by itself does a better job of addressing the problem I'm trying to solve (essentially column stacking, and using the multiplicity to predict the size of the end array so I can allocate it in advance).

So, no bug for me.  Never would have found that vi on my own though.

Thanks again!
0 Kudos
Message 11 of 12
(710 Views)
One thing to remember is that an array can have multiple modes. For example [1,2,2,3,4,4,5] has modes 2 and 4. They both occur at the highest frequency (count=2).
 
I made a quick implementation for integer arrays, but it could be easily adapted for DBL arrays.
 
See attached (LabVIEW 7.1). It is not fully tested, so please verify operation. 😉
 
Inputs: Integer array of any length (including empty array)
Outputs: (1) count of elements of mot frequent element, (2) array of modes (elements that occur "count" times in input array.
0 Kudos
Message 12 of 12
(620 Views)