D=[1.08  1.99  1.46  1.21  1.48  2.50  2.62  1.95
1.19  2.10  1.21  0.96  0.62  0.88  0.68  0.48
1.22  1.91  1.36  0.90  0.65  1.52  1.32  0.95
0.60  1.10  1.03  0.61  0.32  2.12  1.48  1.09
0.55  1.00  0.82  0.52  1.48  0.90  0.75  0.44];
Y=X(:,1:3);% Lets just look at the first three variable (columns)
[n,p]=size(Y); % get the dimension of the data 
I=eye(n); % create an identity matrix
j=ones(n,1); % create a column of ones
J=ones(size(I)); %create a matrix of ones
ybar=(1/n)*Y'*j; % the mean vector
S=(1/(n-1))*Y'*(I-(1/n)*J)*Y; % unbiased variance-covariance matrix
S=(1/(n-1))*(Y'*Y-(1/n)*Y'*J*Y);
