# correlation of two signal

30 views (last 30 days)
ali hassan on 24 Nov 2020
Commented: ali hassan on 24 Nov 2020
hello buddies and experts.
need little help.
i am actually correlating two signals. i want to circ shift the signal by (-1.9282e-12) and then find this delay by delay command.
code:
% t=linspace(0,1000,100001) %in ms
xs=randn(1,100001)
grid on
subplot(3,1,1)
plot(t,xs)
shift_ms = 10;
subplot(3,1,2)
plot(t,x1)
[c,lags]=xcorr(xs,x1);
subplot(3,1,3)
plot(lags,c)
title('CORRELATION OF RECEIVER 1 AND PROCESSING UNIT')
[maxval indx]=max(c)
shiftCalc_ms = (length(t)-indx)/10
t21 = finddelay(xs,x1)
output:
##### 2 CommentsShowHide 1 older comment
ali hassan on 24 Nov 2020

Bjorn Gustavsson on 24 Nov 2020
Why do you want to use circshift? That would put some of your last samples first! That's not the way to go about this.
To do this right you have to calculate the number of samples that corresponds to your requested time-shift, that is you have to take your sampling-frequency and calculate how many samples corresponds to 1.9e-12. If that is a full number of samples then you know how many steps to circular-shif with. BUT: Then you definitely have to crop out that number of samples to avoid including the product between samples from the beginning and end of the time-serieses, how to do that you can rather easily figure out if you take a small toy-array with say 10-15 elements and look at where samples end up after the circ-shifting.
HTH
ali hassan on 24 Nov 2020
great sir and appreciated!!
sir could you plzz tell the code.will beof immense help.
BEST REGARDS