COUNT_MATRIX_ELEMS
COUNT_MATRIX_ELEMS - Obtains unique row elements from MxN matrix A and counts the number of occurrences. UN contains all matrix A distinct elements. C will have the same size as UN. UN(k) has C(k) occurrences in matrix A.
Example:
A = [1 2 3; 4 5 6; 1 2 3; 4 5 7; 1 2 1; 1 2 3; 4 5 6]
[UN, C] = count_matrix_elems(A)
A =
1 2 3
4 5 6
1 2 3
4 5 7
1 2 1
1 2 3
4 5 6
UN =
1 2 1
1 2 3
4 5 6
4 5 7
C =
1
3
2
1
See also UNIQUE, FIND, NUMEL
Cite As
Paulo Coelho (2024). COUNT_MATRIX_ELEMS (https://www.mathworks.com/matlabcentral/fileexchange/38680-count_matrix_elems), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
count_matrix_elems/
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 |