//exec('intdec.5_10.code')
 
 xinit('intdec.5.ps')
 xf=24:-1:0;
 xf(26:50)=xf(25:-1:1);
 xs=real(fft(xf,1));
 x=xs(26:50);
 x(26:50)=xs(1:25);

 l=8;
 m=5;

 forder=33;

//Get dimensions of vectors

   hsize=forder;
   xsize=maxi(size(x));
   xlsize=(xsize-1)*l+1;
   xhsize=xlsize+hsize;

//Design FIR low-pass filter with cut-off frequency fco=min(fr/2,l*fr/(2*m))

   fr=.5*xsize/(xhsize-1);
   fco=mini([fr,l*fr/m]);
   [hffir,w]=ffir('pb',forder,fco,'hm');
   h=l*hffir';

//upsample x by putting l-1 zeroes between each sample

   xl(1:l:xlsize)=x;

//prepare xl for linear convolution 

   xl(xlsize+1:xhsize-1)=0*ones(1:hsize-1);

//prepare h for linear convolution

   hl=0*ones(xl);
   hl(1:hsize)=h;

//circular convolution by fft

   hlf=fft(hl,-1);
   xlf=fft(xl,-1);
   yl=real(fft(hlf.*xlf,1));

//remove leading and trailing elements due to partial convolution with h

   hso2=ent(hsize/2);
   ylmod=yl(hso2+1:xhsize-hso2-1);

//downsample ylmod by taking every mth sample

   y=ylmod(1:m:xhsize-2*hso2-1);

 plot(x)
 xend()
 xinit('intdec.6.ps')
 plot(abs(fft(x,-1)))
 xend()
 xinit('intdec.7.ps')
 plot(abs(hlf))
 xend()
 xinit('intdec.8.ps')
 plot(abs(xlf))
 xend()
 xinit('intdec.9.ps')
 plot(abs(xlf.*hlf))
 xend()
 xinit('intdec.10.ps')
 plot(y)
 xend()


