% 2-d correlation 
clear
x=[1 -1 3 2;
    2 1 2 4;
    1 -1 2 -2;
    3 1 2 2]; % input
y=[1 2 1;
    3 1 2;
    1 0 1]; % input
rxy=xcorr2(x,y) % crossocorrelation
% xcorr2(y,x)
x=[2 2 3;
    3 -1 2;
    1 2 1]; % input
rxx=xcorr2(x,x) % autocorrelation


