discretize
Bin numeric values into discrete categories.
Syntax
Section titled “Syntax”Y = discretize(X, edges)Y = discretize(X, N)[Y, E] = discretize(X, ...)Description
Section titled “Description”Sorts the values of X into bins. With edges (a vector of bin edges), each X(i) is assigned an integer index — the bin it falls into. With N (an integer count), the range is split into N equal-width bins. Optional second output E returns the bin edges actually used.
Examples
Section titled “Examples”discretize([0.1 0.5 0.9], [0 0.3 0.7 1]) % [1 2 3]discretize([1 2 3 4 5], 2) % [1 1 2 2 2]See also
Section titled “See also”histogram— Histogram of data.categorical— Create a categorical array from data.