필터 지우기
필터 지우기

How can i find,most and less reapted number in array or matrix?

조회 수: 2 (최근 30일)
Farhad
Farhad 2015년 5월 20일
댓글: Farhad 2015년 5월 20일
i have a matrix like:X=[1 3 3 3 3; 3 7 4 4 4; 4 7 5 5 5; 5 9 8 8 8 ] in this matrix most repeated number is 3 and less repeated number is 1 and 9.i want to sort number by times of repeated.how can i do this? Thanks

채택된 답변

Andrei Bobrov
Andrei Bobrov 2015년 5월 20일
X=[1 3 3 3 3; 3 7 4 4 4; 4 7 5 5 5; 5 9 8 8 8 ];
c = unique(X(:));
z = histc(X(:),c);
out = sortrows([c,z],2);

추가 답변 (1개)

Image Analyst
Image Analyst 2015년 5월 20일
Is this homework? Sounds like it. Why not try histcounts()? Or histc if you have an old version of MATLAB. It's a good chance to learn about histograms and the several MATLAB functions related to histograms.
  댓글 수: 1
Farhad
Farhad 2015년 5월 20일
no,i am working on a project,i have 1800 data and i want to sort them by times of repeated,i use mode() function to finde more repeated number but it is not enough.

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

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by