N-D histogram
HISTCND Histogram count for n dimensional data.
N = HISTCND(X,EDGES), for row vectors X, counts the number of values in
X that fall between the grid defined by the cell array of EDGES, each
of whose element is a vector that contain monotonically non-decreasing
values. N is an N-D array each of whose dimension corresponds to
LENGTH(EDGES{j}) and each element contains a count of data that falls
into the edge.
X is N-by-D matrix representing N data points in D dimensional space.
EDGES must have the same length to the number of columns of X.
Alternatively, EDGES can be a numeric vector which gives a uniform
grid for all dimensions of X.
N(k1,k2,...) will count the vector X(i,:) if for each dimension
j = 1,2,..., EDGES{j}(kj) <= X(i,j) < EDGES{j}(kj+1). The last bin will
count any values of X that match EDGES(end). Values outside the values
in EDGES are not counted. Use -inf and inf in EDGES to include all
non-NaN values.
[N,BIN] = HISTCND(X,EDGES) also returns subscript indices BIN.
BIN is zero for out of range values.
Example:
>> X = randn(100,2); % 100-by-2 row vectors
>> edges = {-2:.4:2,-2:.5:2}; % ranges for each dimension
>> histcnd(X,edges)
ans =
0 0 0 1 1 1 0 0 0
0 1 1 2 1 1 0 0 0
1 0 3 4 0 3 0 0 0
0 1 2 1 3 0 1 0 0
0 3 1 4 2 1 3 1 0
1 1 2 3 3 4 1 0 0
0 1 1 2 1 1 4 0 0
0 1 2 2 2 1 0 0 0
1 2 0 3 2 0 0 1 0
0 1 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
Cite As
Kota Yamaguchi (2026). N-D histogram (https://uk.mathworks.com/matlabcentral/fileexchange/30798-n-d-histogram), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.0.0.0 |
