barttest
              Bartlett’s test of sphericity for correlation.
It compares an observed correlation matrix to the identity matrix in order to check if there is a certain redundancy between the variables that we can summarize with a few number of factors. A statistically significant test shows that the variables (columns) in x are correlated, thus it makes sense to perform some dimensionality reduction of the data in x.
 ndim = barttest (x, alpha) returns the number of
 dimensions necessary to explain the nonrandom variation in the data matrix
 x at the alpha significance level. alpha is an optional
 input argument and, when not provided, it is 0.05 by default.
 [ndim, pval, chisq] = barttest (…) also
 returns the significance values pval for the hypothesis test for each
 dimension as well as the associated chi^2 values in chisq
Source Code: barttest