%% Autocovariance of Random Vector
% Create a 20-by-1 random vector, then compute and plot the estimated autocovariance. The largest spike occurs at zero lag, where the vector is exactly equal to itself.

rng default
x = rand(20,1);
[c,lags] = xcov(x);
stem(lags,c)

% Copyright 2018 The MathWorks, Inc.