04-15-2012 10:46 AM - edited 04-15-2012 10:47 AM
Here is a 2 minute modification that works with any row size and can be changed to any array input data type by simply changing the representation of the input array (Try DBL, CDB, U64, I8, etc.).
04-15-2012 12:29 PM
@altenbach wrote:
Quote: "Hello, I'm sorry for my english. I have a 2D numeric array with thousends of rows and 2 columns. "
If the problem were posed differently, I would have posted different code. 😉
Sometimes I just need to read more carefully before jumping into a thread, especially when trying to comment on it well after midnight local time. Thanks for sharing your code - I'll definitely have learned something once I figure out what it is doing.
In case anyone's curious, Altenbach's VI is a 20x improvement over my method, and over 300x faster than SteveM's simple direct method.
12-14-2015 10:40 PM - edited 12-14-2015 10:41 PM
Hi all,
Sorry to reignite an old thread, but I'm working on a problem very similar to this right now and I'm wondering if any of you can help me out!
I have a very similar 2D array of integers, but instead of extracting the unique rows only, I'd like to keep the first instance of each duplicate row. In other words, I'd just like to delete the duplicates, without deleting the row that they're duplicating, if that makes any sense. My array is probably no more than 10 rows long, so a slow solution would work just fine.
Ex.
Input Array:
0 0
0 0 -> delete
0 1
1 0
0 1-> delete
2 0
2 1
Output Array:
0 0
0 1
1 0
2 0
2 1
Any tips you have would be helpful, thank you!
12-14-2015 11:16 PM
Right now, I'm working with a slightly modified version of the original solution for simplicity (I'm relatively new to LabVEIW and didn't quite understand all of the components of the full solution).
Essentially I've attempted to take the output array from the solution that stevem181 posted, and search that array again for to see if the row has been added yet. If you're a stickler for efficiency I'm sure you're cringing at this point...
The issue I'm having is that when I test it with the following array I get an extra row that I don't want, and I'm not sure where it's coming from:
Input Array:
2 3
2 3
2 0
Output Array:
0 0
2 3
2 0
It seems the VI is working as intended, except for that pesky (0, 0) row. Additionally, the following occurs:
Input:
2 3
2 3
2 0
0 0
Output:
0 0
2 3
2 0
0 0
... I'm lost. Any ideas?
12-14-2015 11:44 PM - edited 12-14-2015 11:45 PM
Sorry, your VI is way too convoluted for my taste. 😉
See if this works for you instead. 😄
12-14-2015 11:59 PM - edited 12-15-2015 12:00 AM
12-15-2015 06:34 PM
That works great, thank you so much!
12-15-2015 08:00 PM