08-03-2015 11:44 PM - edited 08-03-2015 11:48 PM
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?
08-03-2015 11:53 PM
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. 😉
08-04-2015 12:16 AM - edited 08-04-2015 12:17 AM
08-04-2015 12:31 AM
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
08-04-2015 12:41 AM
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!
08-04-2015 01:07 AM - edited 08-04-2015 01:08 AM
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: