How to find mode between two columns?

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?

 Accepted Answer

MATL
[u,~,c] = unique(a,'rows');
[~,ix]=max(accumarray(c,1));
mdrows=u(ix,:);
Encapsulate in function for general use.

1 Comment

Sandy
Sandy on 10 Jul 2013
Edited: Sandy on 10 Jul 2013
Works perfectly! Thanks!

Sign in to comment.

More Answers (0)

Asked:

on 9 Jul 2013

Community Treasure Hunt

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

Start Hunting!