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 array, categorical, strings, or cell array of character vectors.
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.
A categorical input has a row or column for every one of its categories,
an unused one included, holding zeros. The chi-square statistic and its
p-value are computed over the rows and columns that hold observations,
where MATLAB returns NaN for both whenever any row or column is
empty.
Source Code: crosstab