How to bin xcorr data ? (averaging time series of binary data into larger bins for cross-correlation analysis)

4 views (last 30 days)
Hi, I have two arrays (time series) - z1 and z2 - related to recordings from 2 different channels. Their size is 1x59898. I am using xcorr to calculate their reciprocal timing or degree of synch at different lags. However the command gives me the output in 6x10^4 (60000) while I would like to get seconds or fractions of seconds. In addition, to make the cross correlation analysis more meaningful I think I should "re-bin" my time series before the analysis. I tried using histcount but it does not do what I want (the vectors are binary (1, 0) so the binning done that way does not work (a lot of data are counted/placed around 0 of course and few data - the events - around the last/highest bin).
This is the code I am using, very banal
z1=t1; %I am just making a copy of my time series not to delete the original one
hold on
subplot(3,1,1)
z1=zeros(1, length(t1)); %create an empty 0 array long as the time series
z1(locs1)=1; %locs contains the indexes of the events previously calculated with "findpeaks". this line just converts the peaks into "1" values
plot(z1) %this plots the times series
z2=t2; %same for the other channel
subplot(3,1,2)
z2=zeros(1, length(t2));
z2(locs2)=1;
plot(z2)
subplot(3,1,3)
[corr,lag] = xcorr(z1, z2);
figure(3)
plot(lag,corr);
Thanks for any advice !

Answers (0)

Community Treasure Hunt

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

Start Hunting!