LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

index of retry data

Hi

I have 1D array(A) contain sequence like:
(A) 1 2 7 5 8 6 6 9 74 14
I build an other array (B) contain specific sequence from (A) array:
(B) 2 5 8 9 14
now i would like to build an array (C) contain the indexes from array (A)
I should have :
(C)1 3 4 7 9

so how to build such array?

Thanks
0 Kudos
Message 1 of 7
(3,503 Views)
You need to search 1D array A with array B which is indexed in a For loop, and then index the results into array C. See attached example in LV 6.0.

Kim
0 Kudos
Message 2 of 7
(3,503 Views)
If array (B) has unique value, you can use the search array function to find the index of each of the elements in array (A). See my example below:
>

"There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
0 Kudos
Message 3 of 7
(3,503 Views)
If (A) has multiple values that match (B), you can use a nested for loop:
>

"There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
0 Kudos
Message 4 of 7
(3,503 Views)
Thanks Kim

but your example doesn't work correctly from index 19 in array (A).
See attached example in LV 6.1
0 Kudos
Message 5 of 7
(3,503 Views)
abdou:

This is a pretty easy task.

Straightforward way to do this is:
1) Create a for loop.
2) Pass in array A and array B.
3) Set array B to auto index.
4) Set Array A NOT to autoindex.
5) Then search Array A for the indexed element from array B using
search 1D array. If array A contains the element from array B, search
1D array will return it's index otherwise it returns -1.
6) Wire the return from search 1D array to the right edge of the for
loop and set it to build array. Wire an indicator to the build array
on the right edge of the for loop.
7) If you want to exclude the -1's (not founds) then you will need to
create a different loop to remove them or build the array inside the
for loop using a shift register and a true false selector and a bui
ld
array on the false side and a pass through on the true side.

Q.E.D.

Douglas De Clue
LabVIEW Programmer
ddeclue@bellsouth.net



abdou wrote in message news:<5065000000080000004F550000-1027480788000@exchange.ni.com>...
> Hi
>
> I have 1D array(A) contain sequence like:
> (A) 1 2 7 5 8 6 6 9 74 14
> I build an other array (B) contain specific sequence from (A) array:
> (B) 2 5 8 9 14
> now i would like to build an array (C) contain the indexes from array
> (A)
> I should have :
> (C)1 3 4 7 9
>
> so how to build such array?
>
> Thanks
0 Kudos
Message 6 of 7
(3,503 Views)
Please save in version LV6.0 as i dont have LV6.1. Unless someone else wishes to help you instead.

Kim
0 Kudos
Message 7 of 7
(3,503 Views)