LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to search and delete multiple matches from 1D array?

Hi I tried to think hard of a way how to search for multiple matches in 1D array from , and delete them from it?
 
Regards,
Clement
0 Kudos
Message 1 of 7
(14,955 Views)

Hi I have found way. I wired it  wrongly to updated array. Anyway. It's for anyone to read it and compare it.

Clement 

0 Kudos
Message 2 of 7
(14,948 Views)

You can

1. Cast 1D array and element to string.

2. Use Search and Replace String.vi.

3. Cast result back to your data type.

Try the attached VI.

0 Kudos
Message 3 of 7
(14,946 Views)

ttrr, I don't think Astorboy has 7.1. BTW, why does your example have my name? Smiley Very Happy

Astroboy, your algorithm is still wrong. The only reason it worked is because you have N,xxx,N,xxx. If you had two xxx's in a row it wouldn't work. Here's another option, but this is also not very good for large arrays, although ttrr's is probably better (at least for strings). You can bench them and try.

For a more complex algorithm, you can try determining the number (and indexes) of elements to remove, initializing a new array and using Array Subset on the original and Replace Array Subset on the new one. You will obviously need to calculate the length and indexes.

 

___________________
Try to take over the world!
Message 4 of 7
(14,940 Views)
Astorboy, if you can not open VI, see the attached picture.
 
BTW, I abbreviate 'Test' to 'Tst'.
0 Kudos
Message 5 of 7
(14,932 Views)
Hi Tst and Ttrr,
I see we have different and shortest methods used for this test. Thanks alot. I learnt alot from your examples.
 
 Clement
 
0 Kudos
Message 6 of 7
(14,916 Views)

As explaned in this recent post, it is extremely inefficient to use "delete from array" inside a loop for this purpose. You should use "replace array element" and trim the unused tail at the end. This is much more efficient!

The attached example (LabVIEW 7.0) shows a quick modification of your VI to implement this (Basically the "replace II" algoritm mentioned in the above link) . In case of large arrays, it will be much more efficient. Let me know if you have any questions. 🙂

Message Edited by altenbach on 08-14-2005 06:35 PM

Message 7 of 7
(14,918 Views)