%% Biased Cross-Covariance of Two Shifted Signals
% Create a signal made up of two signals that are circularly shifted from each other by 50 samples.

rng default
shft = 50;
s1 = rand(150,1);
s2 = circshift(s1,[shft 0]);
x = [s1 s2];

% Compute and plot biased estimates of the autocovariance and mutual cross-covariance sequences. The output matrix c is organized as four column vectors such that {\tt c}=\pmatrix{c_{s_1s_1}&c_{s_1s_2}&c_{s_2s_1}&c_{s_2s_2}\cr}. c_{s_1 s_2 } has maxima at -50 and +100 and c_{s_2 s_1 } has maxima at +50 and -100 as a result of the circular shift.

[c,lags] = xcov(x,'biased');
plot(lags,c)
legend('c_{s_1s_1}','c_{s_1s_2}','c_{s_2s_1}','c_{s_2s_2}')

% Copyright 2018 The MathWorks, Inc.