LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reversing a 2D array by Row and removing duplicates

here is an array VI that can be used to remove duplicate items from a 2D array.  It gives the option to reverse the array row in case you want the most recent data set or the first data set.
 
Best regards
Tim C.
1:30 Seconds ARRRGHHH!!!! I want my popcorn NOW! Isn't there anything faster than a microwave!
Message 1 of 12
(8,560 Views)

I should mention that I used a VI found in this discussion group as a based layout, there you go, no intallectual propetry violations 🙂

 

1:30 Seconds ARRRGHHH!!!! I want my popcorn NOW! Isn't there anything faster than a microwave!
0 Kudos
Message 2 of 12
(8,554 Views)
Are you asking for people to critique it, or are you asking why it's slow? 

If you provide an 8.2 version more people will be able to take a look at it. Smiley Wink
0 Kudos
Message 3 of 12
(8,553 Views)
He's just throwing it out there in case anyone wants it.  the 1:30 seconds is his signatureSmiley Wink
0 Kudos
Message 4 of 12
(8,547 Views)
I figured as much, but it would still be nice to have an 8.2 version available to look at for those (like me) who don't have 8.5, unless he's doing something that's specific to 8.5.
0 Kudos
Message 5 of 12
(8,544 Views)
Now that we agree upon
0 Kudos
Message 6 of 12
(8,540 Views)
Tim C.

Thanks for posting the program.  You should try posting it on our brand New NI Developer Zone Community.  This portion of our site has been specifically designed to promote code sharing between developers such as yourself.  To sign in use the same email and password you use for our forums. 

You can get to the Developer Zone Community from the ni.com main page by selecting NI Developers Zone » LabVIEW Zone » Code Sharing



Let me know if you have any questions about Developer Zone Community.  Feedback is always welcome and appreciated!



Mark
NI App Software R&D
0 Kudos
Message 7 of 12
(8,509 Views)
Here are a few ways to improve things:
  • Don't use spaces in filenames. Most browsers replace them with %20 when downloading, making the name very messy. You could use underscores.
  • Fill the input array with some useful default data containing duplicates and multiple rows so the reversal makes a difference and we can test right away. Currently the default value is a single row of 3 A's. producing a result of 3 A's. Pretty boring.
  • Since the output array is typically smaller, it would make sense to do the reversal at the end, not the beginning. Less work! I am actually not sure why you combine two seemingly unrelated functions into a single VI (remove duplicates, reverse columns). It might be more versatile to make it into two atomic VIs with one function for each.
  • Building 2D arrays in loops can cause low performance with large arrays due to memory reallocation issues. This is a prime example where everything could be done "in place", followed by trimming at the end. Try it! 🙂 It will be orders of magnitude faster for large datasets.
  • Not everybody is blessed with 30" screens, there is too much whitespace and we constantly need to scroll to see the big picture.
  • You have too many wire bends. In this case, the main 2D array should be a single horizontal line from beginning to end. It makes the code much more readable.
  • For this to be useful as a subVI, you would also need to also create connectors for the boolean and column selector.
  • If you would index inside the second loop for the desired element, you could eliminate the allocation of the entire test column and also eliminate a second autoindexing input tunnel.
  • A single case structure is enough, you can use boolean logic to combine the selectors (if "different" _OR_ "i=1", for example). 
  • If you would index the lower shift register with a value that can never occur, you could eliminate the "=0" comparison and the entire outer case structure. Even if you retain that case structure, you can wire [i] directly to the selector and make one case "0" and the other "default". Less clutter. 🙂
0 Kudos
Message 8 of 12
(8,501 Views)


altenbach wrote:
  • Since the output array is typically smaller, it would make sense to do the reversal at the end, not the beginning.

Actually, I take that back, because the results will potentially differ because we only look at one column.
 
You should also place your name on the VI and possibly some contact information.
0 Kudos
Message 9 of 12
(8,491 Views)

After that scathing review I don't know if i want to put my name on it Smiley Wink

Thanks for the tips, alway appreciate the vetrrans feedback

-Tim C

 

1:30 Seconds ARRRGHHH!!!! I want my popcorn NOW! Isn't there anything faster than a microwave!
0 Kudos
Message 10 of 12
(8,463 Views)