フィルターのクリア

Finding all rows in matrix matching rows in another matrix

46 ビュー (過去 30 日間)
Niels Brummerstedt
Niels Brummerstedt 2019 年 9 月 5 日
回答済み: madhan ravi 2019 年 9 月 5 日
I'm trying to get all row indices in matrix B which are equal to any row from matrix A.
I tried
A = [1 0 1 0; 0 1 0 1];
B = [1 1 0 0; 0 1 1 0; 1 0 1 0; 1 0 1 0; 0 0 1 1; 0 1 0 1];
[~,indB] = ismember(A,B,'rows')
However, the output was
indB =
3
6
where I need to obtain
indB =
3
4
6
How would this be achieved?
Thanks in advance!

採用された回答

madhan ravi
madhan ravi 2019 年 9 月 5 日
indB = find(ismember(B,A,'rows'))

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by