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

16 ビュー (過去 30 日間)
Turbulence Analysis
Turbulence Analysis 2024 年 4 月 10 日 18:38
コメント済み: Star Strider 2024 年 4 月 10 日 19:13
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.

採用された回答

Star Strider
Star Strider 2024 年 4 月 10 日 18:48
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 件のコメント
Turbulence Analysis
Turbulence Analysis 2024 年 4 月 10 日 19:00
Thanks very much! works perfectly!
Star Strider
Star Strider 2024 年 4 月 10 日 19:13
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by