[sig_t, sig_a]=textread('8mls_sig.txt', '%n%n');
[seq]=textread('8mls_sequence.txt');
seq=[seq;seq];
N=length(sig_a);
cor = diag(zeros(N));
for n=1:N
cor(n)=sum(sig_a .* seq(n:(n+N-1)));
end
plot(cor);
xlabel('sequence offset');
n = find(cor==max(cor), 1); % find best n
bestSig = seq(n:(n+N-1));
fprintf('Best signal is for shifted by \n');
n
fprintf('%d',bestSig);
fprintf('\n');

