LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

numeric case structure

Im having a hard time creating a numeric case structure that has the following cases:

<1
between 1 and less than 2
between 2 and less than 3

It seems that this will not work using 1..2, for example, because that 2 will also fall in range of case 2..3

Please advise

0 Kudos
Message 1 of 9
(9,426 Views)
Well the main problem is that the selector on a numeric case structure is an integer. Notice the red coercion dot appears when you wire a float to the selection? Hence there are no values between 1 and less than 2, or between 2 and less than 3.

One thing you can do is rescale your float and then convert it into an integer. For example, say you multiply your input value by 1000. Now you can have ranges that approximate what you are wanting:
..999
1000..1999
2000..2999
3000..
Alternately you can use comparison functions with nested boolean case structures. (I prefer the first solution - less complicated.)

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 2 of 9
(9,417 Views)
Just round to -infinity and convert to integer.
 
Make the cases:
 
"..1" for anything below 1
"1" for 1 .. 1.9999999999999999999
"2" for 2 .. 2.9999999999999999999
etc.
Also add a default case.
 

Message Edited by altenbach on 07-21-2007 10:37 PM

Message 3 of 9
(9,409 Views)

Hi Altenbach,

Atleast in LV 7.1, it is NOT allowing to add the case "1,2" after adding the case "..1". It tells that the case structure values are NOT unique.

Please see the attached VI & clarify me...

- Partha ( CLD until Oct 2024 🙂 )
Download All
Message 4 of 9
(9,371 Views)

Sorry, the first case needs to be "..0" of course. You cannot have the "1" in two different cases.

Your lower case structure is also wrong, because you have overlapping ranges. For example an input of 0 will match both "..1" and "..2". Right? For any given input, there can only be exactly one matching case or you get an error.

Message Edited by altenbach on 07-23-2007 12:08 AM

Message 5 of 9
(9,368 Views)
Thanks guys

Yes the problems of overlapping and using non-integers are certainly there and, knowing that I will allow the user up to three decimal places, I used the suggestion of multiplying by 1000, which worked great, so its "..1000" , "1001..2000", etc.

Thanks guys for your help
0 Kudos
Message 6 of 9
(9,334 Views)

Hi guys,

I want to have a case structure with two cases one is when the number is infinity and else, can you give me ideas how to do such a case structure thank you

0 Kudos
Message 7 of 9
(7,481 Views)

Question was put into a new thread:

http://forums.ni.com/t5/LabVIEW/case-strucute-with-infinity-and-else-as-two-cases/m-p/3206092/highli...

 

Please proceed discussion there.


Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 8 of 9
(7,464 Views)

You can type "inf", "-inf" into float numerics. Also there are special constants in numeric palette. Then comparison function

PS I would start a new thread, ksm is very surprised now, his 8 years old question...

0 Kudos
Message 9 of 9
(7,448 Views)