How do I know if the finddelay function is significant?
5 views (last 30 days)
Show older comments
I am currently using the finddelay function to visualize a wave pattern. I have a matrix with periodic signals recorded and I use one of the signals as a reference to which I compare all of the others to achieve a matrix of delays which I then visualize as different colours in a matrix plot.
I my case I would assume to have sufficient correlation with the majority of the signals but what do the function actually return for the few that does not have a correlation? Will I get 0 as delay? I have looked into the code of the function but could not figure it out by myself. Would it be possible to adapt the function to get it to return a special value when there is no correlation so that I could single out and mark theses spots in my plot?
Related to this I also wonder if there is some general rule of how long this type of signals should be for the finddelay function to be applicable?
Thank you, Emelie
0 Comments
Answers (2)
Wayne King
on 28 Apr 2013
Edited: Wayne King
on 28 Apr 2013
It is not true that you will get back a delay of zero for cases when the signals are not significantly correlated at any lag.
rng default;
x = randn(100,1);
y = randn(100,1);
[xc,lags] = xcorr(x,y,20,'coeff');
[rho,idx] = max(abs(xc));
lags(idx)
And cross-correlation sequences that achieve a maximum at zero lag can certainly indicate significant cross-correlation. Think about the autocorrelation of a sequence.
Depending on what distributional assumptions you can reasonably make about your signals, it may well be possible to come up with a principled threshold for significant cross-correlation, but just for the moment, let's assume you want to see at least 0.5
You can do something like this
[xc,lags] = xcorr(x,y,20,'coeff');
[rho,lags] = max(abs(xc));
if (rho>=0.5)
Lag = lags(idx);
else
Lag = NaN;
end
Wayne King
on 27 Apr 2013
If the signals are equal length, then why not use xcorr() with the 'coeff' option?
Then the cross-correlation will lie in the range [-1,1] and you pretty easily assess how significant the cross-correlation is when it achieves its maximum.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!