function d=fordiff(x,n)
% forward difference of sequence x applied n times
d=x;
for i=1:n
   m=length(d);
   d=d(2:m)-d(1:(m-1));
end

   
   