function Mary = CorrMHTE_ECE588(r1, r2)
%%%% Components of signal vectors 
s11 = 1; s12 = 0;
s21 = xfix({xlSigned, 24, 20, xlRound, xlWrap}, 0.70710678);s22 = s21;
s31 = 0; s32 = 1;
s41 = xfix({xlSigned, 24, 20, xlRound, xlWrap}, -0.70710678);s42 = s21;
s51 = -1; s52 = 0;
s61 = s41;s62 = s41;
s71 = 0;s72 = -1;
s81 = s21;s82 = s41;
%%% Computation of correlation metrics
c1 = s11*r1 + s12*r2;c2 = s21*r1 + s22*r2;c3 = s31*r1 + s32*r2;c4 = s41*r1 + s42*r2;
c5 = s51*r1 + s52*r2;c6 = s61*r1 + s62*r2;c7 = s71*r1 + s72*r2;c8 = s81*r1 + s82*r2;
%%%% Decision 
    if c1 > c2 & c1 > c3 & c1 > c4 & c1 > c5 & c1 > c6 & c1 > c7 & c1 > c8
    Mary = 0;Mary = xfix({xlSigned, 3, 0, xlRound, xlWrap}, Mary);
elseif c2 > c1 & c2 > c3 & c2 > c4 & c2 > c5 & c2 > c6 & c2 > c7 & c2 > c8
    Mary = 1;Mary = xfix({xlSigned, 3, 0, xlRound, xlWrap}, Mary);
elseif c3 > c1 & c3 > c2 & c3 > c4 & c3 > c5 & c3 > c6 & c3 > c7 & c3 > c8
    Mary = 2;
elseif c4 > c1 & c4 > c2 & c4 > c3 & c4 > c5 & c4 > c6 & c4 > c7 & c4 > c8
    Mary = 3;Mary = xfix({xlSigned, 3, 0, xlRound, xlWrap}, Mary);
elseif c5 > c1 & c5 > c2 & c5 > c3 & c5 > c4 & c5 > c6 & c5 > c7 & c5 > c8
    Mary = -4;;Mary = xfix({xlSigned, 3, 0, xlRound, xlWrap}, Mary);
elseif c6 > c1 & c6 > c2 & c6 > c3 & c6 > c4 & c6 > c5 & c6 > c7 & c6 > c8
    Mary = -3;Mary = xfix({xlSigned, 3, 0, xlRound, xlWrap}, Mary);
elseif c7 > c1 & c7 > c2 & c7 > c3 & c7 > c4 & c7 > c5 & c7 > c6 & c7 > c8
    Mary = -2;Mary = xfix({xlSigned, 3, 0, xlRound, xlWrap}, Mary);
elseif c8 > c1 & c8 > c2 & c8 > c3 & c8 > c4 & c8 > c5 & c8 > c6 & c8 > c7
    Mary = -1;Mary = xfix({xlSigned, 3, 0, xlRound, xlWrap}, Mary);  
else
    Mary = 4;Mary = xfix({xlSigned, 3, 0, xlRound, xlWrap}, Mary);
end