Searching for the most frequently occurring cell in a cell array.
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi! I have an array < 1x99cell >, where every cell has 2 objects as, [3 4] [4 5] [3 5] ....[5 4] and i want to find the most common cell, i am thinking to convert each cell to a number like 34, 45, 35, ...,54 and after this to find the most frequently number.
Have anyone any idea for this? Thanks!
댓글 수: 0
채택된 답변
Azzi Abdelmalek
2013년 4월 3일
편집: Azzi Abdelmalek
2013년 4월 3일
A={[4 5], [1 2], [3 4], [1 2],[4 5],[1 2]}
a=cell2mat(A')
b=unique(a,'rows')
for k=1:size(b,1)
numb(k)=sum(ismember(a,b(k,:),'rows'));
end
result=[b numb'] % numb' is the third column of result and correspond to the frequency of each element
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!