function [corr,corrcoeff,media,varianza] = correlazione(x,k) %function [corr,corrcoeff,media,varianza] = correlazione(x,k) %x: matrice processo aleatorio %k: elementi correlazione e coefficiente di correlazione media=mean(x); varianza=var(x); for m=1:size(x,2)-k %if rem(m,500)==0, m, end for n=0:size(x,2)-m-1 corr(m,n+1)=mean(x(:,m).*x(:,n+m)); corrcoeff(m,n+1)=(corr(m,n+1)-media(m)*media(n+m))/(varianza(m)*varianza(n+m))^.5; end end end