function R = xcorrm(x,p)

c = xcorr(x,p);
c = c(fix(length(c)/2)+1:end)/(length(x)-1);

for i=1:p
  for j=i:p
   R(i,j) = c(j-i+1);
  end
end
for i=1:p
  for j=i:p
   R(j,i) = c(j-i+1);
  end
end
clear c;
clear p;
clear i;
clear j;