필터 지우기
필터 지우기

Does cross correlation indeed give correct signal leg value?

조회 수: 3 (최근 30일)
Shivani Agarwal
Shivani Agarwal 2021년 8월 27일
답변: Chunru 2021년 8월 28일
I want to find the position of signal [3,4] in signal [1,2,3,4,5,6] using cross correlation and thus xcorr function
x = [1,2,3,4,5,6];
y = [3,4];
[a,b] = xcorr(x,y);
a = [0,0,0,0,4,11,18,25,32,39,18];
for leg values b = [-5 -4 -3 -2 -1 0 1 2 3 4 5];
thus max value is 39, i.e. at right shift of 4 but signal there is [5,6] not [3,4] i.e. at the right shift of 2
This is a very basic operation, I am not getting why it's not giving correct results, could someonne please tell what I am missing here?

답변 (1개)

Chunru
Chunru 2021년 8월 28일
Correlation will give the correct signal delay estimate when signal to noise ratio is sufficiently high.
Consider a signal x is a delayed version of the template y:
%x = [1,2,3,4,5,6];
x = [0,0,3,4,0,0];
y = [3,4];
[a,b] = xcorr(x, y)
a = 1×11
0 0 0 0.0000 0 0 12.0000 25.0000 12.0000 -0.0000 0
b = 1×11
-5 -4 -3 -2 -1 0 1 2 3 4 5
It can be observed that the peak occus at the time lag of 2, indicating the signal template y is delayed by 2 in signal x.
When small amount of noise added, the estimate of the peak is still correct:
x = [0,0,3,4,0,0] + randn(1,6)*0.2
x = 1×6
0.2324 -0.0266 2.8088 4.2078 -0.2091 0.0202
y = [3,4];
[a,b] = xcorr(x, y)
a = 1×11
0.0000 0 0 0.0000 0.9297 0.5908 11.1552 25.2576 11.7872 -0.5464 0.0606
b = 1×11
-5 -4 -3 -2 -1 0 1 2 3 4 5
However, when you keep increase the noise level, the estimate may be wrong.
In your code:
%x = [1,2,3,4,5,6];
x = [0,0,3,4,0,0] + [1 2 0 0 5 6]; % second term can be considered as noise
y = [3,4];
[a,b] = xcorr(x, y)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by