syrioosh
Newbie level 2
Hello
I m trying to estimate time delay between signals using cross correlations.
Unfortunately I ve encountered a few problems I m unable to handle.
Here is code what I ve done. According to article I ve read it is supposed to be working.
I m expecting at the last figure, one peak which should indicate a delay between signals x1, and xr, but there isnt any
I m not very familiar with all this sutff, so please be tolerant
I look forward to receiving any help.
Thank you in advance
Here s code
I m trying to estimate time delay between signals using cross correlations.
Unfortunately I ve encountered a few problems I m unable to handle.
Here is code what I ve done. According to article I ve read it is supposed to be working.
I m expecting at the last figure, one peak which should indicate a delay between signals x1, and xr, but there isnt any
I m not very familiar with all this sutff, so please be tolerant
I look forward to receiving any help.
Thank you in advance
Here s code
Code:
%Cross correlation
N = 256;
n = 0:N-1;
D= 32;
alpha = 0.7
wn = 1*randn(size(0:1:255)) %generating noise
x1 = 5*[ones(1,4),zeros(1,N-4)]; % source 1
xd = 5*[zeros(1,D),ones(1,4),zeros(1,N-D-4)]; % delayed source
xr = alpha*xd+wn; % recived source
Y = xcorr(xr,x1);
R = Y(1:N);
Rrx = fliplr(R);
% Plots
subplot(411)
plot(n,x1);
title('Clear signal');
xlabel('Time')'
ylabel('Amplitude');
grid;
subplot(412)
plot(n,xd);
title('Delayed signal');
xlabel('Time');
ylabel('Amplitude');
grid;
subplot(413)
plot(n,xr);
title('Recivied signal');
xlabel('time');
ylabel('Amplitude');
grid;
subplot(414);
plot(n,Rrx);
title('Autocorrelation');
xlabel('lags');
ylabel('Autocorrelation');
grid;