<< nan_hist2res Descriptive Statistics nan_histo >>

NaN Toolbox >> NaN Toolbox > Descriptive Statistics > nan_histc

nan_histc

Produce histogram counts.

Calling Sequence

n = nan_histc(y,edges);
n = nan_histc(y,edges,dim)
[n,idx] = nan_histc (...)

Description

When y is a vector, the function counts the number of elements of y that fall in the histogram bins defined by edges. This must be a vector of monotonically non-decreasing values that define the edges of the histogram bins. So, n(k) contains the number of elements in y for which edges(k) <= y < edges(k+1). The final element of n contains the number of elements of y that was equal to the last element of edges.

When y is a N-dimensional array, the same operation as above is repeated along dimension dim. If this argument is given, the operation is performed along the first non-singleton dimension.

If a second output argument is requested an index matrix is also returned. The idx matrix has same size as y. Each element of idx contains the index of the histogram bin in which the corresponding element of y was counted.

Examples

x = -2.9:0.1:2.9;
y = rand(10000,1,'normal');
n_elements = nan_histc(y,x);
c_elements = cumsum(n_elements);
bar(x,c_elements);

Authors


Report an issue
<< nan_hist2res Descriptive Statistics nan_histo >>