10-29-2014 02:33 PM
Let's say I have a case structure that switches on a number. Obviously I can define a range for a given case, i.e. 0..4, 5..8, 9..100.
But what if I want those ranges defined by variables? i.e.
MIN_A = 0
MAX_A = 4
MIN_B = 5
MAX_B = 8
MIN_C = 9
MAX_C = 100
is there a way to create a case structure to where I can enter those variables as the range?
I know an alternative woulud be to simply compare the number to those ranges and switch on true-false and nest the case structures, but didn't know if I could do it directly as described above.
10-29-2014 02:42 PM
Wow, that's a good question! It seems like a very useful feature though. Of course it begs the question of what happens if conflicting ranges are entered during run-time.
Now I'm curious as to what some of the LabVIEW gurus around here are going to say about it...
10-29-2014 02:51 PM
10-29-2014 02:59 PM
This is interesting question.
I think you could wire in your min and max variables to couple of 'In Range and Coerce' functions, and based on the outcome generate an enum value for example. Then you can use that enum wired in to a case structure.
10-29-2014 05:29 PM
GerdW wrote:
put those numbers in an array and use Interpolate1DArray to find the corresponding range!
It takes care of overlapping ranges - somehow… 😄
I think what you really want is Threshold 1D Array. That will give the "index" of the value you give it. It does assume a constantly rising array, but that shouldn't be much of an issue. Then you just put this index into the case selector.
10-30-2014 04:17 AM
I'd go for 3 In range and Coerce, and an AND to combine them. Maybe there's a slimmer way.
/Y
10-30-2014 06:58 AM
@Yamaeda wrote:
I'd go for 3 In range and Coerce, and an AND to combine them. Maybe there's a slimmer way.
/Y
Why the AND? Or do you mean Build Array and then Boolean Array to Number?
10-30-2014 09:19 AM
@crossrulz wrote:
@Yamaeda wrote:
I'd go for 3 In range and Coerce, and an AND to combine them. Maybe there's a slimmer way.
/Y
Why the AND? Or do you mean Build Array and then Boolean Array to Number?
Unless i misunderstood, there are 3 different variables that needs to be in range, bool array to number would also be a solution if the other combinations are of interest.
/Y