LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

labview number classification

Solved!
Go to solution

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.

0 Kudos
Message 1 of 6
(2,985 Views)

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.

0 Kudos
Message 2 of 6
(2,982 Views)

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.

0 Kudos
Message 3 of 6
(2,971 Views)
Solution
Accepted by topic author steinhoff

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

 

 

0 Kudos
Message 4 of 6
(2,964 Views)

Wow didn't thought it that way, I missed to arrange everything with arrays, thank you very much!

0 Kudos
Message 5 of 6
(2,959 Views)

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:

check.png

 

Btw. in your example given in msg #3 you should note what happens for "1.5"! Is it belonging to range A or B?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 6
(2,955 Views)