Y=[ 30  21  21  14 ;
    22  13  22   5 ;
    29  13  18  17 ;
    12   7  16  14 ;
    23  24  23   8 ];
[n,p]=size(Y);
I1=eye(n);
j1=ones(n,1);
ybar=(1/n)*Y'*j1
J1=ones(size(I1));
S1=(1/(n-1)) *Y'*(I1-(1/n) *J1)*Y
C=[ 1  1 -1 -1;
    1 -1  1 -1;
    1 -1 -1  1];
T_Square=n*(C*ybar)'*inv(C*S1*C')*(C*ybar)
t1=sqrt(n)*C(1,:)*ybar*(1/sqrt(C(1,:)*S1*C(1,:)'))
t2=sqrt(n)*C(2,:)*ybar*(1/sqrt(C(2,:)*S1*C(2,:)'))
t3=sqrt(n)*C(3,:)*ybar*(1/sqrt(C(3,:)*S1*C(3,:)'))