필터 지우기
필터 지우기

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 CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by