将数据分组为垃圾箱或类别
[___] =离散化(___,'categorical')
创建一个分类数组,其中每个垃圾箱是一个类别。在大多数情况下,默认类别名称是表单“[A,B)
” (or “[A,B]
“在最后一个垃圾箱),在哪里A
andB
是连续的箱边缘。如果您指定dur
as a character vector, then the default category names might have special formats. SeeY
有关显示格式的列表。
[___] =离散化(___,'categorical',
, for datetime or duration array inputs, uses the specified datetime or duration display format in the category names of the output.displayformat.
)
[___] =离散化(___,'IncludedEdge',
,在哪里side
)side
is'left'
or'对'
, specifies whether each bin includes its right or left bin edge. For example, ifside
is'对'
, then each bin includes the right bin edge, except for the第一垃圾箱包括两个边缘。在这种情况下,j
th bin包含一个元素x(i)
if边缘(j) < X(i) <= edges(j+1)
,在哪里1 < j <= N
andN
is the number of bins. The first bin includes the left edge such that it contains边缘(1)<= x(i)<=边缘(2)
。该default forside
is'left'
。
行为离散化
类似于histcounts
function. Usehistcounts
to find the number of elements in each bin. On the other hand, use离散化
to find which bin each element belongs to (without counting).