Find similar elements in a matrix
이전 댓글 표시
My question is that , I have a matrix, I want to know which element from which columns are similar, which number is the most repeated number for example
X=[1 2 3 3 3
45 7 4 4 4
70 8 5 5 5
88 9 11 11 11
170 205 13 13 13
172 220 14 23 24
194 222 24 24 41
196 224 41 152 67
200 539 62 183 68
250 540 67 184 71
251 1415 68 185 148
255 1426 71 187 151
]
for example here 3 (repeated in columns 3,4 and5) the same for 4, 5, 1, 13
and the most repeated numbers are 3,4,5,11, and 13
댓글 수: 2
Grzegorz Knor
2011년 9월 5일
I've question:
most repeated numbers are 3,4,5,11, and 13
or rather
most repeated numbers are 3,4,5,11, 13 and 24?
Niki
2011년 9월 5일
채택된 답변
추가 답변 (2개)
Grzegorz Knor
2011년 9월 5일
My suggestion:
[u, ~, n] = unique(X);
[h1 h2] =hist(n,unique(n));
u(h2(h1==max(h1)))
댓글 수: 3
Niki
2011년 9월 5일
Grzegorz Knor
2011년 9월 5일
There is 45 zeros:
sum(X(:)==0)
Is this OK?
Niki
2011년 9월 5일
카테고리
도움말 센터 및 File Exchange에서 Univariate Discrete Distributions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!