LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

if condition

Hi, I try to creat a vi to result the folowing statement:
 
if 0<= x<=0.05, d=4;
 else if 0.5 <x <= 0.1 d=3.5;
    else if 0.1 <x <=0.2, d=3;
      else if 0.1 <x <= 0.2, d=2.5;
   .........
      else if 1.6 <x<=3, d=0.5;
 
when i use the case structure in labview, it's too many case statements.
 
caould you tell me some easy way?
 
many thanks
0 Kudos
Message 1 of 10
(4,243 Views)
case statements in LabVIEW can handle numeric inputs (polymorphism...), but this works only with integers.
A simple solution to your problem is to multiply the x value by 100, juste to create integer values, then to create the corresponding cases. Remember that a case statement accept "lists and ranges of values in the case selector label at the top of the Case structure. For lists, use commas to separate values. For numeric ranges, specify a range as 10..20, meaning all numbers from 10 to 20 inclusively. You also can use open-ended ranges. For example, ..100 represents all numbers less than or equal to 100, and 100.. represents all numbers greater than or equal to 100". The quotes delimit a chunk of the LV help.
Chilly Charly    (aka CC)
0 Kudos
Message 2 of 10
(4,231 Views)
Hi,
 
The best way is to use the "Formula Node" and write the complete C code in it.
Message 3 of 10
(4,228 Views)


TSreedhar a écrit:
Hi,
 
The best way is to use the "Formula Node" and write the complete C code in it.




Well, I don't think that a lot of people here will consider this as the best solution ! 😉 Remember that most of us are "C impaired" people :D. That's just why we use labVIEW : to forget about textual code !
Chilly Charly    (aka CC)
0 Kudos
Message 4 of 10
(4,223 Views)


srt wrote:

if 0<= x<=0.05, d=4;
 else if 0.5 <x <= 0.1 d=3.5;
    else if 0.1 <x <=0.2, d=3;
      else if 0.1 <x <= 0.2, d=2.5;
   .........
      else if 1.6 <x<=3, d=0.5;
<=3, d="0.5;
 

This is just an example, right?

You are not trying to assign a value to d = 3 or 2.5 based on 0.1<x<=0.2 

If the above formula is true, then what value gets assigned if x is between 0.11 to 0.2?

I would implement the approach suggested by CC.  

Ray

Message 5 of 10
(4,220 Views)

And yet another "G-reat" approach uses the in-range and search 1-d array to give you the ability to

change ranges and "D" values at run-time by replacing the constants with controls.

X is compared with each of the ranges specified by the costants.

The resulting boolean array is searched for the first "true" and the index tells which "D" value to select.

 

Ben

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 6 of 10
(4,199 Views)
I think this solution is really good. Its worse to complicate things by multiplying with 100 and mess around with the code. That was really nice Ben.
0 Kudos
Message 7 of 10
(4,188 Views)
Even simpler...

Message Edité par chilly charly le 10-19-2005 04:01 PM

Chilly Charly    (aka CC)
Download All
Message 8 of 10
(4,178 Views)
svp aidez
c'est urgent
je veus réaliser un filtre passe bas en labview de f(p)=wn²/wn²+2xip+p²
pour xi<0.7
xi=0.7
0.7i<xi
voila mon e-mail:fat_na@hotmail.com
0 Kudos
Message 9 of 10
(4,148 Views)
Hey this speaks of a cool solution too... thanks a lot.
0 Kudos
Message 10 of 10
(4,123 Views)