counting number of times a values appears in file
    조회 수: 6 (최근 30일)
  
       이전 댓글 표시
    
i have a file with numbers like...
1
2
3
4
2
1
6
4
and so on...
i want to count how many times each number appears in above file.. how to do that??
댓글 수: 0
답변 (2개)
  Andrei Bobrov
      
      
 2014년 9월 12일
        a = [1, 2, 3, 4, 2, 1, 6, 4]';
a1 = unique(a);
out = [a1 histc(a,a1)];
댓글 수: 0
  Naama
 2014년 9월 12일
        You can use hist (assuming that you import your data to the x vector):
[count, bin] = hist(x, min(x):max(x));
where count contains the frequency of the numbers in bin.
댓글 수: 0
참고 항목
카테고리
				Help Center 및 File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


