
function[as,ps,s,K]=aawelch(x,w,D,L)
%function[as,ps,s,K]=aawelch(x,w,D,L);
%M=length(w)=section length;
%L=number of samples desired in the frequency domain;
%w=window(@name,length of sample=length(w));x=data;
%D=offset distance=fraction of length(w),mostly 50% of M;M<<N=length(x);
N=length(x);
M=length(w);
K=floor((N-M+D)/D);%K=number of processings;
s=0;
for i=1:K
    s=s+aaperiodogram(x(1,(i-1)*D+1:(i-1)*D+M),w,L);
end;
as=(abs(s)).^2/(M*K);%as=amplitude spectral density;
ps=atan(imag(s)./real(s))/(M*K);%phase spectral density;
