%% P-Values of Matrix
% Compute the correlation coefficients and p-values of a normally distributed, random matrix, with an added fourth column equal to the sum of the other three columns. Since the last column of A is a linear combination of the others, a correlation is introduced between the fourth variable and each of the other three variables. Therefore, the fourth row and fourth column of P contain very small p-values, identifying them as significant correlations.

A = randn(50,3);       
A(:,4) = sum(A,2); 
[R,P] = corrcoef(A)

% Copyright 2015 The MathWorks, Inc.