Hello all, I am still struggling with this and I don't know why its producing wrong answer. I have my two signals and I want to produce the delay time between the two signals and see if they both originate from the same source or not so delay time is not known and the two signals might not be from the same source..I have many source data and I need to do it for any two then calculate the delay time.the problem is that I only get large positive numbers for the delay and if I swap x,y in the xcorr argument I get totally different answer and I believe I should get the same answer as the x,y but opposite sign (minus/positive)…
Thank you all in advance,
x = sample1(:,1);X = (x).';y = sample2(:,1);Y = (y).';figure;clfsubplot(3,1,1);[xi,f]=ksdensity(X); plot(f,xi); line(repmat(X,2,1),repmat([0;0.1*max(xi)],1,length(X)),'color','r' ); subplot(3,1,2);[xi,f]=ksdensity(Y); plot(f,xi); line(repmat(Y,2,1),repmat([0;0.1*max(xi)],1,length(Y)),'color','r' );[Rxx,lags] = xcorr(X,Y);[Z,delay] = max(Rxx);lags(delay);
Best Answer