Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How can I use xcorr to determine the amount of offset between one signal and another?

determine offset signal
0
Posted

How can I use xcorr to determine the amount of offset between one signal and another?

0

The following M-file demonstrates how to use xcorr to determine how much offset exists between two signals, x1 and x2 : t=0:.01:1.01; x1=[t.^2]; % generate sample data x2=[0 0 0 t.^2]; % x2 is delayed version of x1, delayed by 4 samples xc=xcorr(x1,x2); % perform cross correlation index=find(xc==max(xc)); % this is the index of the cross correlation where % the cross correlation is at its maximum. I.e. % this is where x1 and x2 line up the best. middle=(length(xc)+1)/2; % this is the middle element (since length(xc) is always % odd) if index-middle>=0, disp([‘x2 is delayed from x1 by ‘ num2str(index-middle)… ‘ sample(s)’]); else disp([‘x1 is delayed from x2 by ‘ num2str(middle-index)…

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.