How to align two signals using xcorr function?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponses (1)
Image Analyst
le 26 Avr 2017
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 commentaire
Image Analyst
le 26 Avr 2017
Maybe you could attach your two signals in a .mat file to help speed this along.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!