07-21-2012 11:14 AM
Hi I'm looking for a fast way for labview to classify numbers by class according to specified ranges. Using the number comparison tools just take me to a huge vi, which is hard to handle.
Solved! Go to Solution.
07-21-2012 11:21 AM
What do you mean by a "class" of numbers? Provide an example of what you are trying to do.
If you mean you are trying to determine if a particular number is within some predefined ranges, then the In Range and Coerce function could help.
07-21-2012 11:47 AM
Thank you for answering. Precisely, I need to determine if a particular number is within some predefined ranges, and according to that, it belongs to a class.
For example
Range A: 1-1.5 -> Class A number
Range B: 1.5-2.3 -> Class B number
Range C: 2.3-3.1 -> Class C number
...
I used the in range function but I need to do this for 64 numbers, and at least 20 ranges, so its a lot of In Ranges for each number, connected to the max and min values. Also, now the numbers can depend on more than one range, so it gets very hard to handle. Just wanted to know if there's another more efficient way to classify them.
07-21-2012 12:28 PM
In Range & Coerce, like most Numeric functions is polymorphic, meaning that its inpus will accept arrays as well as scalars. When the inputs are arrays the outputs are also arrays. If the arrays are different lengths, the shorter array determines the length of the output arrays.
Then scan through the boolean array (Coerced?) to find the class.
Lynn
07-21-2012 01:06 PM
Wow didn't thought it that way, I missed to arrange everything with arrays, thank you very much!
07-21-2012 01:16 PM - edited 07-21-2012 01:17 PM
Hi steinhoff,
you can also utilize Threshold1DArray for this matter...
You define the input array for that function to contain the start of each range. Then you use a FOR loop to scan all your numbers for their range:
Btw. in your example given in msg #3 you should note what happens for "1.5"! Is it belonging to range A or B?