The crosstab function will do this--it is not limited to 2x2 tables. Example:
n = 200;
Gender = randi(2,n,1);
Group = randi(4,n,1);
[tbl,chi2stat,pval] = crosstab(Gender,Group)
34 24 22 26
21 30 23 20
Table shows you the number in each of the 2x4 combinations of group and gender.
chi2stat is the value of the chi-square statistic, here with 3 degrees of freedom. The null hypothesis being tested is that the proportions of males vs females are the same for all four groups. Or, equivalently, that the proportional distribution across the 4 groups is the same for males vs females.
The null would be rejected if pval is small, typically less than 0.05.