Effacer les filtres
Effacer les filtres

Finding corresponding rows in two matrices

2 vues (au cours des 30 derniers jours)
Rachel
Rachel le 5 Juin 2012
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.

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 5 Juin 2012
[i1,i1] = ismember(desc1(5,:),desc2,'rows')

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by