LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to implement if then else?

Hey Friends,

if i want to make a program (if the input is x and L).

if the x is less than -L output must be 0

if the x is between -L and 0 output must be 1

if the x is between 0 and L output must be 2

if the x is more than L output must be 3.

What should be done(since there isnt any if then else commnad in labview)?

 

Thanks in advance

 

Regards

0 Kudos
Message 1 of 16
(14,036 Views)

@interstellar wrote:

(since there isnt any if then else commnad in labview)?


The "else" in LabVIEW is the false case

 

IF x Then (do the True case) else (do the False case)

Just like you nest IF ELSE statements in text based, you also nest True/False cases in LabVIEW

Omar
0 Kudos
Message 2 of 16
(14,025 Views)

Thanks..  is there any other way?

0 Kudos
Message 3 of 16
(14,018 Views)

The case selector will accept a number.  You can also have ranges for a case (e.g.    0..5 is zero to five).

 

Check the help on case structures.

 

http://zone.ni.com/reference/en-XX/help/371361B-01/glang/case_structure/

 

http://digital.ni.com/public.nsf/websearch/A5D77ADCA661670386256A480062A340?OpenDocument

 

 

>

"There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
0 Kudos
Message 4 of 16
(14,011 Views)

ElseThen.png

Omar
0 Kudos
Message 5 of 16
(14,005 Views)

Your first and fourth rules are both true in this case, but this is a convenient way to test multiple criterion.

 

ifthenelse.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 6 of 16
(14,001 Views)

I know you can do this with a formula node.  Not sure how performance compares to other methods.

0 Kudos
Message 7 of 16
(13,964 Views)

Thanks for your reply.. 

cant the range be variable.. like for this case L?

0 Kudos
Message 8 of 16
(13,941 Views)

DON'T DO THIS!!!!  There's a note in a style guide, somewhere, that says something ugly about nesting too many Case Structures.  It's tempting, though, and more analagous to If-Then-Else than my first response.

ifthenelse_BD.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 9 of 16
(13,939 Views)

I did this initially but this did not look nice and was difficult to understand..

 

What if i want to use case structure. like what vt92 said

The case selector will accept a number.  You can also have ranges for a case (e.g.    0..5 is zero to five).

 

Check the help on case structures.

 

http://zone.ni.com/reference/en-XX/help/371361B-01/glang/case_structure/

 

http://digital.ni.com/public.nsf/websearch/A5D77ADCA661670386256A480062A340?OpenDocument

 

cant in place of number a variable be used? like in my example 'L'...

0 Kudos
Message 10 of 16
(13,927 Views)