LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to only "if statement" using case structure

I have a two dimensinal array. The first column contains an array with elements as 0,0,0,1,1,1,2,2,3,3,3,4,4,5,5,5,6,6,6,....etc. The second third and fourth columns contians the some other data. In my progam when ever the previous element is not equal to the current element in the first column I have to take the data from other columns and store in an array. For this I made a for loop and when ever there is a trnasition in the first column I am activating a case structure. The problem is when ever the case is not actuated it is asking for a defualt value. Is there anyway to disable the default value and write to the array only when there is a transition in the first column. To give a better idea I am attaching my
VI with this question. This VI is a Sub VI of another program.
0 Kudos
Message 1 of 3
(2,667 Views)
There are different ways to do this. The most obvious one is to build the arrays inside the if case everytime it's true and keep the previous arrays in shift registers...however this rapidly becomes a (very)costly operation due to all the array resizing.

So - to make the code efficient you first need to find out how large the result arrays will be, then initialize shift registers with arrays of that size and finally do replace element operations inside the loop instead.

In the attached revision I have shown one way of doing this. I've not tested it in any way, just threw it together... and there may be errors/bugs but you'll probably get the idea.

Mads
Message 2 of 3
(2,667 Views)
Thanks Mads it works exactly the way I want.

Mudda.
0 Kudos
Message 3 of 3
(2,667 Views)