필터 지우기
필터 지우기

How to find mode between two columns?

조회 수: 2 (최근 30일)
Sandy
Sandy 2013년 7월 9일
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?

채택된 답변

dpb
dpb 2013년 7월 9일
MATL
[u,~,c] = unique(a,'rows');
[~,ix]=max(accumarray(c,1));
mdrows=u(ix,:);
Encapsulate in function for general use.
  댓글 수: 1
Sandy
Sandy 2013년 7월 10일
편집: Sandy 2013년 7월 10일
Works perfectly! Thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Random Number Generation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by