Cross Correlation lag issue

조회 수: 3 (최근 30일)
Mustafa Al-Nasser
Mustafa Al-Nasser 2022년 10월 3일
댓글: Mustafa Al-Nasser 2022년 10월 3일
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));

답변 (1개)

Chunru
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))
rho2 = 7.7737
imax = 10
hold on
plot(lags2(imax), xc2(imax), 'r*')
  댓글 수: 4
Chunru
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.
Mustafa Al-Nasser
Mustafa Al-Nasser 2022년 10월 3일
Ok now I found the problem and I am find the lag at which cross correlation is max
but actually my problem is that i am dealing with real signal which is very noisy , so, i am looking to use low pass filter or smooth signal to remove the noise but I have a concern that I may lose some useful information

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by