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!