www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/CorrelationCoefficientsOfMatrixExample.m

    %% Random Columns of Matrix 
% Compute the correlation coefficients for a matrix with two normally
% distributed, random columns and one column that is defined in terms of
% another. Since the third column of |A| is a multiple of the second, these
% two variables are directly correlated, thus the correlation coefficient
% in the |(2,3)| and |(3,2)| entries of |R| is |1|.

% Copyright 2015 The MathWorks, Inc.

x = randn(6,1);
y = randn(6,1);
A = [x y 2*y+3];
R = corrcoef(A)