LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Mode vi return NaN

Solved!
Go to solution

I am using the mode function to calculate the mode value of an array and it returns NaN. LabVIEW help says it only returns NaN when array input is empty. I am not sure why this happen. My array is

0.00015

0.000114

0.000146

0.000188

0.000139

I did try with mulitple value of intervals.

 

DebugMode.PNG

Thanks in advance.

0 Kudos
Message 1 of 7
(3,969 Views)

I think your number of intervals needs to be less than or equal to the input array size.

 

If you set it to a negative number then it should always return the most commonly occuring value instead of using bins.

0 Kudos
Message 2 of 7
(3,960 Views)

Kyle97330,

I have just tried to use -1 but it is still does not work.

 

I am not sure NaN means it cannot find the repeat value or not.

0 Kudos
Message 3 of 7
(3,908 Views)
Solution
Accepted by topic author NTT

NaN in this case means that no mode was found.  Look at it this way... you have a group of numbers and are telling LabVIEW to break it up into 1000 separate "bins". If each bin has only 1 value in it, then there is no mode - no single value that appears more often than other values.

 

For your data set, any number of intervals < = 14 will return a mode.  Any > 15 will return NaN.

 

Message 4 of 7
(3,901 Views)

Hi NTT,

 

I did try with mulitple value of intervals.

For interval = [1, 10] it works nicely - means it gives an output different to NaN…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 7
(3,895 Views)

Thanks Bowen,

Actually I have just found out the answer by using the historgram. It illustrated the reason very clear to me.

0 Kudos
Message 6 of 7
(3,894 Views)

Thanks Gred, I got this now.

0 Kudos
Message 7 of 7
(3,872 Views)