Time Delay Estimation for Monotonically Increasing Funcitons
Afficher commentaires plus anciens
I am trying to use cross correlation to find the time delay between two signals. Both signals follow a logarithmic growth pattern, but are sampled for the same amount of time and at the same sample rate. The only difference between the two is: 1) random noise, and 2) the time delay of when the delayed signal starts. When trying traditional cross correlation here it is failing to find the shift and only reports a maximum at zero delay. Please see the attached matlab code for full details
for i = 1:5
signal1 = 6 + ...
(-0.1 + (0.1+0.1).*rand([1399,1])); %base signal + noise
%simulates the base noisefloor
timeDelay = randi(700);%quantify a random delay
exponentialContrib = log(1:1399) + ...
(-0.1 + (0.1+0.1).*rand([1399,1]))';
signal1(timeDelay:end,1) = signal1(timeDelay:end,1)' + ...
exponentialContrib(1,1:1399-timeDelay+1);
%Second signal with the exponential starting right away
signal2 = 6 + ...
(-0.1 + (0.1+0.1).*rand([1399,1]));
%aligned to zero time
timeDelay2 = 1;
exponentialContrib = log(1:1399) + ...
(-0.1 + (0.1+0.1).*rand([1399,1]))';
signal2(timeDelay2:end,1) = signal2(timeDelay2:end,1)' + ...
exponentialContrib(1,1:1399-timeDelay2+1);
%Find the delayed time
[acor,lag] = xcorr(signal2',signal1');
[~,Idx] = max(abs(acor));
lagTimeCalculated = lag(Idx);
figure; plot(signal1); hold on; plot(signal2);
legend('signal 1', 'signal 2'); hold off;
pause(2);
disp(['Calculated: ' num2str(lagTimeCalculated) ...
' Actual: ' num2str(timeDelay) ' , ' ...
num2str(lagTimeCalculated - timeDelay)]);
end
I believe I know why this is, I am just unsure about how to fix it. As the non-delayed signal is slid through all possible delays, the large-valued logarithmic tail goes from being multiplied by another, time-delayed logarithmic function (as is the case when shift = 0) to being multiplied partially by zeros. This ensures that the correlation intensity will not be greater when both signals truly overlap.
Any comments or suggestions would be greatly appreciated
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Correlation and Convolution dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!