LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

labview logic

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;

Boldness has genius, power and magic in it!'
0 Kudos
Message 1 of 6
(2,601 Views)

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).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 6
(2,599 Views)

check attached code


I am not allergic to Kudos, in fact I love Kudos.

 Make your LabVIEW experience more CONVENIENT.


Message 3 of 6
(2,589 Views)

Now here is a good reason to read the Rube Goldberg thread.

There is more than one way to skin a cat.

!0.png

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)


"Should be" isn't "Is" -Jay
Message 4 of 6
(2,571 Views)

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...

 

Message 5 of 6
(2,568 Views)

@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)

 

$20B40BED3E5E010B.jpg


Kudos are the best way to say thanks 🙂
Message 6 of 6
(2,546 Views)