How to align two signals using xcorr function?

2 ビュー (過去 30 日間)
Arletta Czernik
Arletta Czernik 2017 年 4 月 26 日
コメント済み: Image Analyst 2017 年 4 月 26 日
Hello,
I need to align two signals presented below:
I use xcorr function:
[acor,lag] = xcorr(PROFILE2,PROFILE1);
[~,I] = max(abs(acor));
lagDiff = lag(I)
I don't know why but lagDiff value is 0.
Could anyone help me?
Arletta

回答 (1 件)

Image Analyst
Image Analyst 2017 年 4 月 26 日
Since the bottom plot will never equal the top plot, unless it's circularly shifted, you might have to replicate the second signal 3 times
PROFILE1 = [PROFILE1, PROFILE1, PROFILE1];
Then try correlating. Be aware that finding the max value in the correlation signal just finds where the sum of the products of the signals is max. This does not necessarily happen when you think the signals are aligned, as a little thought will reveal to you. As an extreme example, what it the first 5 values of PROFILE1 had a value of a billion? Where do you think the max element will be?
  1 件のコメント
Image Analyst
Image Analyst 2017 年 4 月 26 日
Maybe you could attach your two signals in a .mat file to help speed this along.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCorrelation and Convolution についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by