% function [c,l]=correl(x) % Calculate and plot the correllation function of a series % Written by Marinna Martini function [c,l]=correl(x); n = max(size(x)); m = mean(x); x = x - m; % remove the mean N = (1/n)*(1/cov(x)); % calculate the normalization factor c = N*xcorr(x); k=max(size(c)) for i=0:k-1, % set up the lags l(i+1)=(-n)+i; end size(l) plot(l,c) title('Correlation Function') ylabel('Magnitude') xlabel('Lag')