%% Correlation Bounds
% Create a normally distributed, random matrix, with an added fourth column equal to the sum of the other three columns, and compute the correlation coefficients, p-values, and lower and upper bounds on the coefficients.

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

%
% The matrices RL and RU give lower and upper bounds, respectively, on each correlation coefficient according to a 95% confidence interval by default. You can change the confidence level by specifying the value of Alpha, which defines the percent confidence, 100*(1-Alpha)%. For example, use an Alpha value equal to 0.01 to compute a 99% confidence interval, which is reflected in the bounds RL and RU. The intervals defined by the coefficient bounds in RL and RU are bigger for 99% confidence compared to 95%, since higher confidence requires a more inclusive range of potential correlation values.

[R,P,RL,RU] = corrcoef(A,'Alpha',0.01)

% Copyright 2015 The MathWorks, Inc.