Function Reference: crosstab

statistics: t = crosstab (x1, x2)
statistics: t = crosstab (x1, …, xn)
statistics: [t, chisq, p, labels] = crosstab (…)

Create a cross-tabulation (contingency table) t from data vectors.

The inputs x1, x2, ... xn must be vectors of equal length with a data type of numeric, logical, char, or string (cell array).

As additional return values crosstab returns the chi-square statistics chisq, its p-value p and a cell array labels, containing the labels of each input argument.

See also: grp2idx, tabulate

Source Code: crosstab