LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Which case to execute?

I have a one dimensional array of numbers (integers) that run from 200 to 400.

 

If the numbers fall between 200 to 378, I want it to execute a certain case.

 

If the numbers are greater than 378 I want it to execute the other case.

 

How do I do this?

 

simple enough but its late and I'm stumped.

 

Thanks

 

mhaque

0 Kudos
Message 1 of 10
(3,601 Views)

See Darren's Weekly Nugget on case structures here.

 

For the full list of what I consider required reading see this. Great information.

Now Using LabVIEW 2019SP1 and TestStand 2019
0 Kudos
Message 2 of 10
(3,590 Views)

Your description is insufficient to give a solution:

 

 

  • Do you want to test each element individually?
  • Do you simply want to make sure that all elements are "in range" and execute a different case if at least one element is outside? ... or if all elements are outside?
For the second case, wire the array to "in range&coerce" with two scalars as limits and do some logic on the boolean output. 

 

 

Message 3 of 10
(3,589 Views)

If i have understood the question properly this is what you are looking in to

 

1.png

Regards
Guru (CLA)
0 Kudos
Message 4 of 10
(3,569 Views)

If the number is less than or equal to 378 I want it to execute the default case.

 

If the number is more than 378 I want it to execute the other case.

 

Ans1) Do you mean each element in the array?

Ans2) No, I want it to excute all the values.

 

Thanks for all your help.

 

I have tried to explain to the best of my ability please let me know if you need further clarification.

 

 

0 Kudos
Message 5 of 10
(3,531 Views)

you're only looking for the FIRST true in the array?  What about all the others values in the array.

If you want to check every value in the array, you will have to use somekind of a loop.

 

If you're just looking for an edge (with 378 as level) then you've found the edge.

 

If you really want to test every value :

I would pass the array through a FOR loop and decide which case to execute :

 

WhichCase.png

Kind regards,

- Bjorn -

Have fun using LabVIEW... and if you like my answer, please pay me back in Kudo's 😉
LabVIEW 5.1 - LabVIEW 2012
0 Kudos
Message 6 of 10
(3,517 Views)

Could you explain further as to why I need some kind of a loop?

 

Essentially I want a numeric indicator coming out of the case structure and not an array of values.

 

Thanks

 

Mahir

0 Kudos
Message 7 of 10
(3,512 Views)

ok, you've got an array of values.  That is a list of values.

 

Every value in this list can be higher or lower then 378?  Not?

 

If not, how do you want to decide which value you want to use for the test?  The maximum from the array?

Kind regards,

- Bjorn -

Have fun using LabVIEW... and if you like my answer, please pay me back in Kudo's 😉
LabVIEW 5.1 - LabVIEW 2012
Message 8 of 10
(3,507 Views)

I've donw what you have told me but I'm getting this error

 

"A Case structure must have a case corresponding to every possible value of the selector.  An easy way to fill this requirement is to specify a default case or cases whose selector values include ranges to or from infinity."

 

How should I label the case strcuture?

 

Will the output array be a 1D array of 2 elements only? 1 corresponding to each case?

 

thanks

 

mhaque

0 Kudos
Message 9 of 10
(3,499 Views)

You forgot the default case.

 

Right click on a case and set it as default. (look at attachement)

 

What my VI will do is, it will test every value in your array and select a case for it and outputs that value.  So your output array will have just as many items as your input array.

 

untitled.JPG

Kind regards,

- Bjorn -

Have fun using LabVIEW... and if you like my answer, please pay me back in Kudo's 😉
LabVIEW 5.1 - LabVIEW 2012
0 Kudos
Message 10 of 10
(3,497 Views)