To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016
Hi everybody, I am cross correlating two signals and plotting the lag times as delays in a histogram to see what the predominant delay is. I am getting a very prominant delag at lag time 0 to -1 hrs and am just wondering what this means in terms of which station is the causative one. By this I mean, which signal is seen first and whis is a result? Thank you for any help
No products are associated with this question.
If you look at the help for xcorr(), you'll see how the inputs are lagged with respect to each other. If the A input is delayed by 4 samples with respect to B and you use:
[xc,lags] = xcorr(A,B,...)
You'll get the maximum at the positive lag 4.
However, if you enter
[xc,lags] = xcorr(B,A,...)
you'll get the maximum at negative lag 4.
B = randn(40,1); % A is a delayed version of B, delayed by 4 samples A = [zeros(4,1) ; B]; [xc,lags] = xcorr(A,B,20); stem(lags,xc) % delay is positive % now reverse order of inputs [xc,lags] = xcorr(B,A,20); figure; stem(lags,xc) %delay is negative
In both cases, the delay is correctly indicated as 4.