LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can i set this comparison in formula node

Solved!
Go to solution

a=[0,100]

a<=5          => x=1

5<a<=10    => x=2

10<a<=95  => x=3

95<a<=98  => x=4

a>98          => x=5

 

Thank you.

 

0 Kudos
Message 1 of 8
(3,299 Views)
Solution
Accepted by topic author keremgeliz

if (a <= 5)
x = 1;
else if (a <= 10)
x = 2;
else if (a <=95)
x = 3;
else if (a <= 98)
x = 4;
else x = 5;

Message 2 of 8
(3,294 Views)

Why use a formula node?

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 8
(3,278 Views)

@GerdW wrote:

Why use a formula node?

check.png


GerdW, you need to add a max value to the end of your array (whatever the max I32 value is).


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
0 Kudos
Message 4 of 8
(3,253 Views)

Hi Crossrulz

 

input "a" is limited to range [0, 100]. Atleast the OP said so…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 8
(3,236 Views)

Thanks for your help. But i need this solution in formula node and i think i fix it. Now its working.

 

if (x<= 5)
a = 1;
else if (x <= 10)
a = 2;
else if (x < 95)
a = 3;
else if (x < 98)
a = 4;
else if (x >= 98)
a = 5;

0 Kudos
Message 6 of 8
(3,216 Views)

Then you should mark BowenM's message as the solution to your question since he was the one who provided you the code that you are now marking as the solution in your message.

 

Actually your last message is wrong since you've gone and swapped the variables a and x from what you had originally described in your original question.

 

Please go to the Options menu to the upper right of your last message, pick unmark as solution, then go and mark BowenM's message as the solution.

 

If it was me, I'd use Gerd's code since it keeps it all in pure LabVIEW functions.

0 Kudos
Message 7 of 8
(3,192 Views)

You copy my code, add an error (given your initial request), post it, and mark it as solution?  Rude.

0 Kudos
Message 8 of 8
(3,186 Views)