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 9
(15,171 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 9
(15,165 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 9
(15,163 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 9
(15,157 Views)
Astorboy, if you can not open VI, see the attached picture.
 
BTW, I abbreviate 'Test' to 'Tst'.
0 Kudos
Message 5 of 9
(15,149 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 9
(15,133 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 9
(15,135 Views)

Devanshi2020_0-1732880883861.png

Here !

0 Kudos
Message 8 of 9
(58 Views)

Devanshi@2020 wrote:

Devanshi2020_0-1732880883861.png

Here !


Other than the fact that you're replying to a 19 year old thread, your solution is both inefficient (I'm guessing altenbach's comments above have some details) and not fully correct. For example, see what happens if add another 3 to your original array.


___________________
Try to take over the world!
0 Kudos
Message 9 of 9
(22 Views)