Finding corresponding rows in two matrices

2 ビュー (過去 30 日間)
Rachel
Rachel 2012 年 6 月 5 日
Hi Everyone,
I have two different 50x20 matrices which are meant to represent 50 objects with 20 properties each.
Without many for loops and if-statements, is there a simple way to find the row in Matrix2 (if any) that corresponds to the same row in Matrix1? As a simple example:
desc1 = zeros(50,20);
desc2 = zeros(50,20);
% Create a unique row we can find
desc1(5,15) = 39;
desc2(19, 15) = 39;
Ideally what I'd like to do is call some built in function F on desc1 and desc2 such that:
F(desc1(5,:), desc2) = 19
Because the element in the 19th row of desc2 is the same as desc1. If there are more than one row of the same entry, I'd like to get a vector with all of them.
Any ideas?
Thanks.

採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 6 月 5 日
[i1,i1] = ismember(desc1(5,:),desc2,'rows')

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by