find matching indexes

11 次查看(过去 30 天)
Zied
Zied 2011-12-2
I have two matrices:
A: x rows and 5 columns
B: x rows and 6 columns (the first column contains indexes)
The values of the matrix A are included in the matrix B. I would like to find the indexes of the matrix A (one row)
  2 个评论
Doug Hull
Doug Hull 2011-12-2
Huh? Please edit the question for clarity.
Chandra Kurniawan
Chandra Kurniawan 2011-12-2
'(the first column contains indexes)' for matrix B or both??

请先登录,再进行评论。

采纳的回答

karan
karan 2011-12-2
Index_find = find(ismember(A,B));
  1 个评论
Daniel Shub
Daniel Shub 2011-12-2
Wow, apparently I guessed wrong about the question. Good work Karan.

请先登录,再进行评论。

更多回答(1 个)

Daniel Shub
Daniel Shub 2011-12-2
I think you want something like
[x, ia, ib] = intersect(A, B(:, 2:end), 'rows');
B(1, ib)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by