フィルターのクリア

finding the row number of a matrix

1 回表示 (過去 30 日間)
Mnr
Mnr 2015 年 11 月 24 日
コメント済み: Mnr 2015 年 11 月 24 日
Hello there,
I have two matrices one A with size MxN and the other one B with size KxN, and rows of B are taken from rows of A. For each row of B, I would like to find the corresponding row in A and store its row number. For instance, let A be:[ -1 -1 -1 -1;-1 -1 -1 1;-1 -1 1 -1;-1 -1 1 1;-1 1 -1 -1;-1 1 -1 1;-1 1 1 -1;-1 1 1 1;1 -1 -1 -1;1 -1 -1 1;1 -1 1 -1;1 -1 1 1;1 1 -1 -1;1 1 -1 1;1 1 1 -1;1 1 1 1]; and B is [-1 1 1 1;1 1 -1 -1;-1 1 1 -1;1 -1 -1 -1;1 1 1 -1;1 1 -1 -1;1 -1 1 1;-1 1 1 1;-1 1 -1 1;-1 1 -1 1;1 1 1 -1;-1 1 -1 1;-1 -1 -1 1;1 -1 1 1;-1 -1 1 1; 1 1 1 1;1 1 1 1;1 1 -1 -1;1 -1 -1 1;1 1 -1 1;1 1 -1 -1;1 1 -1 -1;1 -1 1 1;-1 -1 -1 1]. I would like to compare each row of B with rows of A and see to which of them is equal. That is, row 1 in B in this example is the same as row 8 in A. Could you help me with a fast way of doing this task? Thank you!

採用された回答

Andrei Bobrov
Andrei Bobrov 2015 年 11 月 24 日
[log1,idxb] = ismember(A,B,'rows');
  1 件のコメント
Mnr
Mnr 2015 年 11 月 24 日
Thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by