Documentation Center 
Linear or rank correlation
RHO = corr(X)
RHO = corr(X,Y)
[RHO,PVAL] = corr(X,Y)
[RHO,PVAL] = corr(X,Y,'name',value)
RHO = corr(X) returns a pbyp matrix containing the pairwise linear correlation coefficient between each pair of columns in the nbyp matrix X.
RHO = corr(X,Y) returns a p1byp2 matrix containing the pairwise correlation coefficient between each pair of columns in the nbyp1 and nbyp2 matrices X and Y.
The difference between corr(X,Y) and the MATLAB^{®} function corrcoef(X,Y) is that corrcoef(X,Y) returns a matrix of correlation coefficients for the two column vectors X and Y. If X and Y are not column vectors, corrcoef(X,Y) converts them to column vectors.
[RHO,PVAL] = corr(X,Y) also returns PVAL, a matrix of pvalues for testing the hypothesis of no correlation against the alternative that there is a nonzero correlation. Each element of PVAL is the p value for the corresponding element of RHO. If PVAL(i,j) is small, say less than 0.05, then the correlation RHO(i,j) is significantly different from zero.
[RHO,PVAL] = corr(X,Y,'name',value) specifies one or more optional name/value pairs. Specify name inside single quotes. The following table lists valid parameters and their values.
Parameter  Values 

type 

rows 

tail — The alternative hypothesis against which to compute pvalues for testing the hypothesis of no correlation 

Using the 'pairwise' option for the rows parameter may return a matrix that is not positive definite. The 'complete' option always returns a positive definite matrix, but in general the estimates are based on fewer observations.
corr computes pvalues for Pearson's correlation using a Student's t distribution for a transformation of the correlation. This correlation is exact when X and Y are normal. corr computes pvalues for Kendall's tau and Spearman's rho using either the exact permutation distributions (for small sample sizes), or largesample approximations.
corr computes pvalues for the twotailed test by doubling the more significant of the two onetailed pvalues.
[1] Gibbons, J.D. (1985) Nonparametric Statistical Inference, 2nd ed., M. Dekker.
[2] Hollander, M. and D.A. Wolfe (1973) Nonparametric Statistical Methods, Wiley.
[3] Kendall, M.G. (1970) Rank Correlation Methods, Griffin.
[4] Best, D.J. and D.E. Roberts (1975) "Algorithm AS 89: The Upper Tail Probabilities of Spearman's rho", Applied Statistics, 24:377379.
corrcoef  corrcov  partialcorr  tiedrank