Count elements/rows

Counts elements in N-DIM matrices & rows in max 2-DIM matrices

You are now following this Submission

This functions results in absolute and relative frequencies of elements in N-dimensional matrices or rows 2-dimensional matrices.

Example:

Example:
x = [Inf NaN NaN
1 2 3
1 2 -Inf
1 2 -Inf
1 2 3
1 2 5
Inf NaN NaN];

yr = count(x, 'rows')
yr =
1 2 -Inf 2 0.2857
1 2 3 2 0.2857
1 2 5 1 0.1429
Inf NaN NaN 2 0.2857

yr = count(x)
yr =
-Inf 2.0000 0.0952
1.0000 5.0000 0.2381
2.0000 5.0000 0.2381
3.0000 2.0000 0.0952
5.0000 1.0000 0.0476
Inf 2.0000 0.0952
NaN 4.0000 0.1905

Cite As

Elleke Janssen (2026). Count elements/rows (https://www.mathworks.com/matlabcentral/fileexchange/12283-count-elements-rows), MATLAB Central File Exchange. Retrieved .

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0.0