
% Made for GNU Octave

bitstream=repmat([1 0 0 0 0 0]',50,1);

rect=ones(64,1)/64;
tri=conv(ones(64,1)/64,ones(64,1)/64);
quad=conv(tri,ones(64,1)/64);

rectout=conv(bitstream,rect,'valid');
triout=conv(bitstream,tri,'valid');
quadout=conv(bitstream,quad,'valid');

vpprect=max(rectout)-min(rectout)

vpptri=max(triout)-min(triout)
improvement = vpptri/vpprect

vppquad=max(quadout)-min(quadout)
improvement = vppquad/vpptri

plot( conv(bitstream,rect,'valid'),'b' )
hold on
plot( conv(bitstream,tri,'valid'),'r' )
plot( conv(bitstream,quad,'valid'),'g' )
hold off

legend('Rectangle','Triangle','Sinc3')
title('ADC value=1/6 duty, Length 64 Moving Average')

