Borrar filtros
Borrar filtros

Finding corresponding rows in two matrices

2 visualizaciones (últimos 30 días)
Rachel
Rachel el 5 de Jun. de 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.

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 5 de Jun. de 2012
[i1,i1] = ismember(desc1(5,:),desc2,'rows')

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by