Borrar filtros
Borrar filtros

How to find mode between two columns?

2 visualizaciones (últimos 30 días)
Sandy
Sandy el 9 de Jul. de 2013
I have two variables . They are each in a column. I want to find the most common pairs between the two columns.
EX:
12 13
12 15
13 19
34 12
15 90
12 13
90 10
12 13
In this case my most common pair would be 12, 13.
How can I do this?

Respuesta aceptada

dpb
dpb el 9 de Jul. de 2013
MATL
[u,~,c] = unique(a,'rows');
[~,ix]=max(accumarray(c,1));
mdrows=u(ix,:);
Encapsulate in function for general use.
  1 comentario
Sandy
Sandy el 10 de Jul. de 2013
Editada: Sandy el 10 de Jul. de 2013
Works perfectly! Thanks!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Random Number Generation 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