dummyvar
statistics: D = dummyvar (group)
Create dummy variables.
D = dummyvar (group) returns a matrix D containing
the dummy variables associated with the grouping variables in group.
Each row in D corresponds to the same observation across all variables
in group and each column in D corresponds to a separate dummy
variable. D is a numeric matrix of double data type containing
ones and zeros.
The grouping variable in group can be specified in one of the following options:
1:max (group).
1:max (group).
categorical column vector, in which case the number and order
of columns in D correspond to the categories returned by
categories (group). Categories that are defined but not present
in group produce columns of zeros. Elements of group that are
<undefined> result in rows of NaN values in D.
cell array with its elements containing grouping variables
specified as any of the above options. Note that all grouping variables in
the cell array must have the same number of observations.
See also: tabulate, grp2idx, grpstats
Source Code: dummyvar