First hAutoCorr = conv(ht,fliplr(ht)); this the autocorrelation of ht you can use xcorr(ht) instead:
hAutoCorr(3) is the maximum that should form the diagonal of correlation matrix hM
the number 2*kk+1 is the equalizer length
if 2*kk+1=5 your correlation matrix 5 x 5 matrix