COUNT_MATRIX_ELEMS

Obtains unique row elements from MxN matrix A and counts the number of occurrences.
166 Downloads
Updated 19 Oct 2012

View License

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
Created with R2012a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Scatter Plots in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!

count_matrix_elems/

Version Published Release Notes
1.0.0.0