Cross correlation negative lag time

41 次查看(过去 30 天)
Sarah
Sarah 2012-9-21
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

回答(2 个)

Wayne King
Wayne King 2012-9-21
编辑:Wayne King 2012-9-21
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.
For example:
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.
  2 个评论
Sarah
Sarah 2012-9-21
Thank you for that it clears things up quite a bit. So whatever parameter is first is the driving parameter, and is seen first if the two signals are plotted on top of one another?
Wayne King
Wayne King 2012-9-21
If you want a signal which is delayed in time relative to another to appear as a positive lag in the cross correlation, then enter that input first.
If you have a model where a signal Y is a delayed version of X, so that
Y(n) = X(n-\tau)
for some positive lag \tau, then if that is what you mean by X is driving Y, then entering
[xc,lags] = xcorr(Y,X);
gives you the maximum at lag \tau (the positive lag \tau)

请先登录,再进行评论。


SANDEEP LINGUTLA
SANDEEP LINGUTLA 2016-10-26
in matlab officetemp file when we do auto correation there is lag of days in negative as days are not negative why the days are negtive in graph shown

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by