LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Remove elements from array of clusters

Here's a page that has a link to my VI:

http://tinyurl.com/go5j

I need to be able to selectively delete elements out of an array of
clusters. I'm pretty sure this VI shows the way NOT to do it, but I'm
stuck. What's the best way? I have to loop through all the elements
because I'm selecting elements for deletion based on only one field in
the cluster. How do I delete an element and keep on going through the
array?

Thanks,
s
0 Kudos
Message 1 of 4
(3,766 Views)
Store your array in a shift register and delete the elements that match your removal criteria. I have modified your VI (LabVIEW 6.1) to do just that. It is important to keep track of the array index since it does not stay aligned as you remove elements. You can use another shift register to track the index.

Daniel L. Press
PrimeTest Corp.
www.primetest.com
0 Kudos
Message 2 of 4
(3,766 Views)

To Dan, thank you. I was looking for this solution.

0 Kudos
Message 3 of 4
(3,234 Views)

@marvin117 wrote:

To Dan, thank you. I was looking for this solution.


It is 12 years later and an old solution is still useful? 😄 Times have changed and better solutions are definitely available.

 

If performance is of any concern (e.g. when used with large arrays), the given solution is very, very inefficient. The "delete from array" function should really never be used inside a tight loop. There are much more efficient solutions that operate in-place.

It also seems silly to retake the timestamp with every iteration of the loop. Once before the loop is probably sufficient.

 

In any case, with any modern LabVIEW version we also have conditional output tunnels, allowing to reduce the code to the size of a postage stamp (see picture below). 😄

 

 

0 Kudos
Message 4 of 4
(3,228 Views)