% function c=covar(x) % Calculate and plot the covariance function of a series % Written by Marinna Martini function c=covar(x); n = max(size(x)); m = mean(x); x = x - m; % remove the mean N = (1/n); % calculate the normalization factor c = N*conv(x,x); % convolve x with itself plot(c) title('Covariance Function') ylabel('Magnitude') xlabel('Lag')