LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Removing specific values from an array

Good day:

 

I'm trying to code a program that does the following transformation:

 

{1, 2, 3, 2, 3, 4, 5, 6, 5, 6, 7} ---> {1, 2, 3, 3, 4, 5, 6, 6, 7}   (Bold numbers have been removed)

 

Technically, I'm trying to do the comparison x_(i+1) >= x_i. If this is false, remove x_(i+1) and the data in the corresponding row.

 

Text-wise I believe it looks like this:

 

for i=2 to Length(A)
   j = i - 1;
   if A[i] < A[j]
      Delete A[i];
   else
end

 

However, I'm having alot of trouble trying to program using a mix of for/case loops and shift registers.

 

Could someone point me in the correct direction?

0 Kudos
Message 1 of 6
(2,889 Views)

What is your LabVIEW version?

 

Show us what you tried!

 

Maybe you should start here and add a shift register to compare current with previous to create the decision for the conditional tunnel. Shouldn't be hard. 😉

0 Kudos
Message 2 of 6
(2,880 Views)

Here's one possibility. Modify as needed.

 

 

0 Kudos
Message 3 of 6
(2,865 Views)

Of course you need to decide how to handle other conditions such as an input of:

 

1,2,3,1,2,4,5,6,5,6,7.

 

Should the output be:

 

1,2,3,2,4,5,6,6,7 (current code)

 

or

 

1,2,3,4,5,6,6,7

0 Kudos
Message 4 of 6
(2,848 Views)

Hi Alten, thanks for your fast reply.

 

It should reread the entire array and ensure that the condition holds for all subsequent values - 1,2,3,4,5,6,6,7.

 

I will try the VI u posted.

 

Thanks again!

0 Kudos
Message 5 of 6
(2,837 Views)

JulianChen wrote:

It should reread the entire array and ensure that the condition holds for all subsequent values - 1,2,3,4,5,6,6,7.


OK, the you need to make a few small modifications. See if this works:

 

 

0 Kudos
Message 6 of 6
(2,808 Views)