%datstats.m - M-file to find statistics
%X=data;
X=z;
n=length(X);
meanx=mean(X);
meanvalue=meanx;
stdx=std(X); 
standarddeviation=stdx;
Xd=detrend(X,0);
sumx=sum(Xd);          
sumx2=sum(Xd.*Xd);
sumx3=sum(Xd.^3);
sumx4=sum(Xd.^4);
varx=stdx.^2;
stdx3=stdx.^3;
stdx4=stdx.^4;
n1=1/(n-1);
n2=1/(n-2);
n3=1/(n-3);
variance=n1*sumx2; 
skewness=n2*sumx3 ./ stdx3;
kurtosis=n3*sumx4 ./ stdx4;
S0=sprintf('\n');
Sa=sprintf('skewness = %5.3f',skewness);
Sb=sprintf('kurtosis = %5.3f',kurtosis);
%disp(S0)
%disp(Sa)
%disp(Sb)
