%Izraèuna korelacijo med a in b, èe sta zamaknjena za t0

function co=correlation(a,b,t0)

t=t0;
while t<0
    t=t+1023;
end;

while t>=1023
    t=t-1023;
end;

c=[a a];

s=0;

tf=floor(t);
td=t-tf;
tc=1-td;

m1=1023-tf;
m2=m1+1;
if m2 == 1024
    m2=1;
end;

for n=1:1023
    s=s+td*a(n)*b(m1)+tc*a(n)*b(m2);
    m1=m2;
    m2=m2+1;
    if m2==1024
        m2=1;
    end;
end;

co=s/1023;
    