function peterwelch( data )
%-- Peter's basic substitute for 'pwelch'

%-- Divide the dataset into seven overlapping sections
%-- make sure the seglength is an even number
seglength = floor(length(data)/8)*2;
%-- Construct a Hann window for that length of data
window = (1-cos(2*pi*(1:seglength)/seglength))/2;
%-- Loop over the seven segments; calculate periodograms, sum them
sumperi = zeros(1,seglength);
for iseg=1:7
  windata = data( (iseg-1)*seglength/2+1 : (iseg+1)*seglength/2 );
  ft = fft(windata);
  sumperi = sumperi + abs(ft).^2;
end
%-- Divide by the number of segments
meanperi = sumperi(1:seglength/2) / 7;
semilogy(meanperi)


