Effacer les filtres
Effacer les filtres

Delete rows in a given array based on values in another array

4 vues (au cours des 30 derniers jours)
Turbulence Analysis
Turbulence Analysis le 10 Avr 2024
Commenté : Star Strider le 10 Avr 2024
Hi,
I have two arrays A (179528104x1) and B (1x9700). Here, in the array A, I need to retain only the rows that contain values present in the array B and delete all other rows.

Réponse acceptée

Star Strider
Star Strider le 10 Avr 2024
Perhaps this —
A = randi(99, 50, 1);
A = 50x1
47 89 42 74 47 16 21 68 21 89
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Abfr = buffer(A,10) % Show Everything In 'A'
Abfr = 10x5
47 55 95 81 17 89 95 38 45 86 42 15 10 33 9 74 86 9 6 58 47 66 17 10 69 16 34 65 7 95 21 88 78 62 93 68 51 56 30 7 21 46 52 86 55 89 68 72 93 94
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
B = randi(99, 10, 1)
B = 10x1
74 38 92 57 99 97 85 55 73 17
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
[ix,v] = ismember(A, B);
C = A(ix)
C = 6x1
74 55 38 17 17 55
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
.
  2 commentaires
Turbulence Analysis
Turbulence Analysis le 10 Avr 2024
Thanks very much! works perfectly!
Star Strider
Star Strider le 10 Avr 2024
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by