LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I use a case structure over a range of inputs?

I have 500 different possible inputs from 0.0 to 49.9

Depending on the data, the inputs must be treated differently. This makes sense to use a case structure.

Now my question is, can you set a case structure to take ranges of numbers.

for example.
Do operation A to all numbers less than 10

Do operation B to all numbers greater than or equal to 10 and less than 20.

Do operation C to all numbers greater than or equal to 20 and less than 30.

and so on...up to 49.9

Is there an easy way to set this up?
0 Kudos
Message 1 of 4
(3,083 Views)
Hi,
first you may wire only integer numbers to case structure input node (question mark).
If you want to do some operation for the range of numbers you just need to
1. change your cursor style to editting tool
2. click on the area where the number of the case is written (I don't know how to call this, but I mean the header of the structure where "0, Default"; "1" and so on is written)
3. write there the range of your numbers like
1..10, or 41.. for example (the last one means all the numbers greater than 41).
4. Add new case and repeat the operations.

The example is attached.

Good luck.

Oleg Chutko.
Message 2 of 4
(3,083 Views)
That's exactly what I was looking for.

Thanks!!
0 Kudos
Message 3 of 4
(3,083 Views)
Evan A Young wrote in message news:<506500000008000000CB6A0000-1031838699000@exchange.ni.com>...
> I have 500 different possible inputs from 0.0 to 49.9
>
> Depending on the data, the inputs must be treated differently. This
> makes sense to use a case structure.
>
> Now my question is, can you set a case structure to take ranges of
> numbers.
>
> for example.
> Do operation A to all numbers less than 10
>
> Do operation B to all numbers greater than or equal to 10 and less
> than 20.
>
> Do operation C to all numbers greater than or equal to 20 and less
> than 30.
>
> and so on...up to 49.9
>
> Is there an easy way to set this up?

There are lots of different ways to do this, depending on which way
you like to write this software, and how muc
h work you want to do.
I suggest the following:
make a case structure with 4 frames, (operation A,B,C,D), then use 4
"in range & coerce.vi" to decide which operation to do depending on
the ranges you set. You run the 4 boolean in range outputs together
as a single number. Then you use this number as the selector for your
case structure. Basically then this means that if ONLY the boolean
for "in range A" is true, your data will go in and execute case A and
so on. The only drawback to this idea is you need to decide what to do
about the default case.
I know this sound kind of complicated, I can make an example if you
really need one, repost here if you need it.
0 Kudos
Message 4 of 4
(3,083 Views)