I am processing some data on MATLAB and obtaining results from the time delay between the two signals, using a cross-correlation signal code prepared by myself from some editions on example give in: https://www.mathworks.com/help/signal/ug/align-signals-using-cross-correlation.html I use the following part to process the cross correlation:
%calculating total number of segments
total_segments_st1=size(segments_selected__st1,2);
%calculate cross correlation
k=0;
for i=1:total_segments_st1
k=k+1;
%calculating delay using cross-correlation
[C_n12(:,k),lag_n12(:,k)]=xcorr(segments_selected__st1(:,i),segments_selected__st2(:,i));
C_n12(:,k) = C_n12(:,k)/max(C_n12(:,k));
%identifying the max. amplitude of the two correlations
[M_n12(:,k),I_n12(:,k)] = max(C_n12(:,k));
t_n12(:,k) = abs(lag_n12(I_n12(:,k)));
end
difference_n12=int2str(t_n12);
delay_n12=abs(str2num(difference_n12)*delta_st2); %final arrival time delay in seconds
segments_selected__st1 and segments_selected__st2 are the two signals containing six windows of 20 seconds. In other words, they are 5000x6 matrix (5000 = 20*250 samples per second). total_segments_st1 have the total number of windows (6), then I run the cross-correlation separately one by one of the 20 s time windows.
My question is: How can I do if I wanna apply a 5 seconds (5*250 = 1200 points) overlap between each time windows? For example, the process start the cross correlation in the first time windows of 5 seconds, then, the next cross correlation will start in the last 5 seconds of the first time window. The third cross correlation will start at the last 5 of that second time window, and from then on it continues until complete all total_segments.
Any suggestion will be very welcomed!
thanks, Guilherme