LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

multivariate case

Solved!
Go to solution

I can do this in MatLab/MATLAB:

 

Capture.PNG

 

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?

0 Kudos
Message 1 of 18
(3,973 Views)

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

0 Kudos
Message 2 of 18
(3,960 Views)

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

0 Kudos
Message 3 of 18
(3,956 Views)

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

0 Kudos
Message 4 of 18
(3,950 Views)

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.

MatLab Junk.png

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
(3,924 Views)
Solution
Accepted by topic author EngrStudent

Capture.PNG

Cases can display in Hex


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

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

 

Lynn

 

0 Kudos
Message 7 of 18
(3,909 Views)

@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?

0 Kudos
Message 8 of 18
(3,908 Views)

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
(3,887 Views)

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

0 Kudos
Message 10 of 18
(3,881 Views)