ismember or setdiff but with different number of columns

2 ビュー (過去 30 日間)
Pelajar UM
Pelajar UM 2022 年 3 月 3 日
回答済み: Jan 2022 年 3 月 3 日
Is there a similiar function that could be used to achieve the following?
A is an array with 1 column
B is an array with 3 columns
C = Find index of rows in B that contain values from A in them.
For exmaple, let's say A has the following rows: 8,6,7
B has the following rows: [1,6,9],[3,5,4],[7,0,2]
C should return 1 and 3, because the first and third rows have values that also appear in array A.

採用された回答

Jan
Jan 2022 年 3 月 3 日
A = [8,6,7];
B = [1,6,9; 3,5,4; 7,0,2];
M = ismember(B, A)
M = 3×3 logical array
0 1 0 0 0 0 1 0 0
C = find(any(M, 2))
C = 2×1
1 3

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by