From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Case structure

Solved!
Go to solution

I have a 1 D array of numbers coming into a case structure within a for loop.

 

I have a certain range of numbers which when the case structure is "true" I want to go through, but when the case structure is false I don't want the numbers to go through as I will be using the numbers which go through to build a new array.

 

What I can't figure out is how to make it that the "false" case structure has nothing going through it as the programs keeps telling me I have to put something within the case structure when the statement is false?

 

Please advise and if someone can draw it out for me I would really appreciate it as I am still new with labview.

0 Kudos
Message 1 of 4
(2,028 Views)

What do you mean by "nothing" going through?

 

I don't think we can draw anything out for you when it isn't clear what you are trying to do.

 

However if you attach your VI, that can give us some clues as to what you are trying to do.

 

You say you are building a new array.  So it sounds like you want either a shift register to store your new array that you either build a new element onto or not.  Or you could use a Conditional Tunnel on your loop.

0 Kudos
Message 2 of 4
(2,019 Views)
Solution
Accepted by topic author IRG

Eliminate the case structure.  Use a FOR loop with an indexing input on the left side for your array, and use a conditional indexing output on the right side. 

0 Kudos
Message 3 of 4
(2,014 Views)

It sounds like you can use the "Use Default if Unwired" option to do what you want. Right click on the output terminal and choose that option. It will output an empty array, which can be concatenated.

 

However, depending on what exactly you want to do with the numbers (in either the true case or in general) you could also use Conditional Indexing, as was already suggested, or simply a Select node and an empty array constant.

 

The advantage of a Case Structure is that you can do some processing (which may require significant CPU usage, time etc) on only the valid data, within the loop. If you use the Select node to do the same, then you'll process all data, and just discard the invalid inputs (the same is true with conditional indexing outputs).

 

Here is an example:

snippet.png


GCentral
0 Kudos
Message 4 of 4
(1,998 Views)