
function[as,ps,s]=aabartlettpsd(x,k,w,L)
%function[as,ps,s]=aabartlettpsd(x,k,w,L)
%x=data;k=number of sections; w=window(@name,floor(length(x)/k));
%L=number of points desired in the FT domain;as=amplitude spectrum;
%K=number of points in each section;ps=phase spectrum;s=periodogram;
K=floor(length(x)/k);
s=0;
ns=1;
for m=1:k
    s=s+aaperiodogram(x(ns:ns+K-1),w,L)/k;
    ns=ns+K;
end;
as=(abs(s)).^2/k;
ps=atan(imag(s)./real(s))/k;