Cross Correlation lag issue
    2 次查看(过去 30 天)
  
       显示 更早的评论
    
Dear Team;
i am conducting cross correlation between two signals using the following code but i am alwyas get the lag at which correlation is max at end of the vector
for example for if both P2 , P1 has length of 100 , lags 2 is 101
i did some preprocessing for the signal such as normalization , remove trend but still results do not change 
when i used finddelay function it alyaws give zero 
what do you think the issue is?
 [xc2,lags2] = xcorr(P2,P3,'coeff');
[rho2,lags2] = max(abs(xc2));
0 个评论
回答(1 个)
  Chunru
      
      
 2022-10-3
        P2 = randn(10, 1);
P3 = [zeros(5, 1); P2];   % P3 is P2 delayed by 5
[xc2,lags2] = xcorr(P2,P3);
plot(lags2, xc2)
[rho2,imax] = max(abs(xc2))
hold on
plot(lags2(imax), xc2(imax), 'r*')
4 个评论
  Chunru
      
      
 2022-10-3
				To know why, you need to show your problem. Your incomplete code can not tell why and we can only show what is right.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
