一、原理
二、实现
clear all
clc
X = [1,2,3; 3,1,1];
[m, n] = size(X);
% meathod one
A = ones(m, m);
X2 = X - (1/m)*A*X;
C1 = (1/(m-1)) * (X2'*X2);
% meathod two
C2 = zeros([n,n]);
for i=1:n
for j=1:n
C2(i,j)=(1/(m-1))*(X2(:,i)'*X2(:,j));
end
end
% meathod three
C3 = cov(X);