LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Compare Two 2D arrays and insert row on match

Solved!
Go to solution

I have two 2D arrays. I want to compare them by searching for the letters in the 1st column of each array. If there is a match insert the associated row from the small array into the large array in column 3, else just keep the original row of the big array. My issue is that the array only retains the last value. I tried implementing an additional for loop with an additional set of shift registers, but I get 
i @@@ #### for all my matched rows.

 

Big Array:

adaml88_3-1592839237375.png

 

Small Array:

adaml88_1-1592838020970.png

Result:

adaml88_5-1592839287818.png

 

Desired Result:

adaml88_6-1592839374346.png

 

VI:

adaml88_7-1592839406754.png

Please help thank you.

 

 

 

0 Kudos
Message 1 of 7
(2,450 Views)

You seem to have multiple b's in each array and it seems you want to cycle through them in the small array if consecutive b's occur in the big array. can you describe the full rules leading to the desired result? Are the arrays guaranteed to be sorted by the first column?

0 Kudos
Message 2 of 7
(2,440 Views)

Yes there are multiple b's, and I want to cycle all the b matches available from the small array. The want to match the 1st alphabetical columns and insert the row from the small array into the big array. The overall goal of this vi is to take the big array and insert rows of the small array where the alphabets match (data aggregation). I do not want to lose any data from the big array and only want to populate it with matching small array rows. 

0 Kudos
Message 3 of 7
(2,434 Views)

See if this can give you some ideas. I am sure it could be simplified further....

 

(of course it assumes that the big array has sufficient empty columns for the replacement)

 

altenbach_0-1592842970008.png

 

 

0 Kudos
Message 4 of 7
(2,423 Views)

Slightly less cryptic, same result:

 

altenbach_0-1592851887099.png

 

0 Kudos
Message 5 of 7
(2,396 Views)
Solution
Accepted by topic author adaml88

And if you really want to only iterate over the small array, here's how that would look like:

(Make sure you understand why the built array is needed ;))

 

Of course this still assumes that both arrays are sorted by the first column.)

 

 

altenbach_0-1592854478696.png

 

 

0 Kudos
Message 6 of 7
(2,391 Views)

Thank you altenbach, all your responses implemented very well.  

0 Kudos
Message 7 of 7
(2,364 Views)