Number of counts in matrix
조회 수: 2 (최근 30일)
이전 댓글 표시
채택된 답변
Voss
2024년 4월 3일
Example:
A = [1 1 2; 2 1 2; 3 1 1]
nnz(A == 1) % number of times 1 appears in A
nnz(A == 2) % number of times 2 appears in A
nnz(A == 3) % number of times 3 appears in A
댓글 수: 4
추가 답변 (1개)
Steven Lord
2024년 4월 3일
Use histcounts with unique (or uniquetol) to generate the bins. You will need to add one more bin at the end since the last bin includes both its edges (unlike the other bins, which only include their left edges.) I would use inf as the right-most end of that last bin.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Debugging and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!