LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

compare and choose

hi,

i have some very simple q, sorry, but i didnt really found any example or help suggestions.

I have 1 input (X) and 1 output (Y) and y = f(x)

for X between 0 and 10: Y = 2
for X between 11-20: Y = 4
for Y between 21-30: Y = 5

and so on...

i try it with case-structure and AND, OR.. but not really succesfull..

Thanx in advance
0 Kudos
Message 1 of 4
(2,872 Views)
A) You may use the case structure with the syntax 0..10 for one number 11..20 for the next.

B) You can also use a nested expression node

(x>=0 && x<=10) ? 1 : (x >=11 && x <= 20)? 2: etc

C) You can make an array constant where the independent variable is the index and the
dependent variable is the index value.

D) You can subtract the limits from smaller to larger until the result goes negative, then return a value.

x-11 < 0 T return 1 F loop
x-21 < 0 T return 2 F loop
Message 2 of 4
(2,870 Views)
Hi,

can you please explain how to initialize the case structure with syntax 0...10 and 20...30 and so on... Case structure allows just single int, or true/false?

example?

Thanx in advance

vedran
0 Kudos
Message 3 of 4
(2,855 Views)
One of the nice things about LV is its polymorphism and the way it immediately tells you you made it a mistake.
A case structure does not allow only boolean or a single integer. You can define multiple numbers by using a comma and to define a range simply USE the syntax 10..20. If you wire an integer into the selector and use 2 periods this will be accepted. If something is not accepted (like using a single period, for a fractional number), you will know about it immediately because the font will turn red.
You can also use, for example, error clusters, strings and enums. Just try playing with it.

___________________
Try to take over the world!
0 Kudos
Message 4 of 4
(2,851 Views)