# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## multivariate case

I can do this in MatLab/MATLAB:

When I try to wire multiple inputs into a case structure then I get wire errors.

These are limited cases, not exhaustive.  These are numeric inputs, not text or boolean.  There has to be a way where I can wire an array or such into a case structure.

What am I doing wrong?

Message 1 of 18
(2,295 Views)

## Re: multivariate case

Hi EngrStudent,

There isn't a way to wire an array or multiple numerics into a case selector.

The first suggestion that comes to mind would be to convert the three numbers to strings and then concatenate them all into one string. Then you could wire the string into the case structure and program each of the possible cases.

This can easily be done using the string conversion VI's.

-----------------------------------------------
Brandon Grey
Certified LabVIEW Architect

Message 2 of 18
(2,282 Views)

## Re: multivariate case

@GrayGrey - inelegant, but on it.  Will let you know how it goes, and kudo appropriately.

Message 3 of 18
(2,278 Views)

## Re: multivariate case

Case structures accept integer numeric types as selectors.

One possibility would be nested case structures with a, b, and c wired to different ones. Another method would be to do some simple math to combine the three inputs into a single numeric value and use that as the selector for one case structure. The difficulty of this approach depends on the ranges of possible values for the inputs.

Lynn

Message 4 of 18
(2,272 Views)

## Re: multivariate case

It is extremely inelegant, but you can do the exact equivalent code with the Select function and comparators.  Note that this code has an "unspecified case" ("None of the above") which you have not defined, but I defined as -12345.

Note -- I absolutely do not recommend doing this in "real code".  Think about what you really want to do (which is almost certainly not "encode a very limited set of three-digit numbers").

Bob Schor

Message 5 of 18
(2,246 Views)
Solution
Accepted by topic author EngrStudent

## Re: multivariate case

Cases can display in Hex

"Should be" isn't "Is" -Jay
Message 6 of 18
(2,237 Views)

## Re: multivariate case

Thanks, Jeff. A very elegant and simple implementation of the concept I had in mind.

Lynn

Message 7 of 18
(2,231 Views)

## Re: multivariate case

@Jeff - I have 2015 so the snippet isn't transferring.  What is the name of the vi that you connect both "A" and "B" to?

Message 8 of 18
(2,230 Views)

## Re: multivariate case

That's "Join Numbers", found on the Numeric Palette under Data Manipulation.  And it definitely is elegant, and does not let you make the mistake of "Oops, there's a case I didn't consider", as the numeric Case statement requires a Case for every possible numbers, hence the "Default" Catch-All (a.k.a. a "Terminal ELSE").

Bob Schor

Message 9 of 18
(2,209 Views)

## Re: multivariate case

It is a shame that this doesn't accept boolean inputs.

Message 10 of 18
(2,203 Views)