07-11-2013 02:08 PM
Can please give me Idees for solving this logic ?
int32 y;
if(x=0)
y=0;
else(x>0 && x<=29)
y=1;
if else(x>=30 && x<=49)
y=2;
else y=3;
07-11-2013 02:16 PM
Wire x into a case structure. You can make the case structure use number ranges. In your case, you want a case that is "0", "1..29", "30..49', and DEFAULT (omit the quotes).
07-11-2013 02:37 PM
check attached code
07-11-2013 03:14 PM
Now here is a good reason to read the Rube Goldberg thread.
There is more than one way to skin a cat.
The top is moderators solution. Mine, on the bottom, does not need to edit code to add more cases. Just build bigger arrays! (Of course thse constants become controls in real life- they are constants for demo only)
07-11-2013 03:19 PM - edited 07-11-2013 03:19 PM
Do you really want an answer of "3" for negative inputs?
If we stick to positive inputs, the following gives equivalent results and is slightly more maintainable, especially of the number of cases is large.
Modify as needed...
07-11-2013 04:17 PM
@MaveenD wrote:
Can please give me Idees for solving this logic ?
int32 y;
if(x=0)
y=0;
else(x>0 && x<=29)
y=1;
if else(x>=30 && x<=49)
y=2;
else y=3;
You had 90% of the solution in your logic. Why not use a formula node?
I've also attached the VI (LabVIEW 2012)