I am trying to write a code for the colculate autocorrelation function. Could you suggest what I'm doing wrong. Thanks in advance
i = 1:199;
U =sin(0.3*i);
sum_1 = 0;
for tau = 1:length(U)
for t = tau:length(U)-1
sum_1 = sum_1+sum(U(t).*U(t+1-tau));
r(tau)=sum_1;
end
end