function xreduced=reduce_with_average(x,N)
	% calculates reduced 
	% x - input vector
	% N size of the filter, i.e. how many points replace with one

	Nsize=length(x);
	Newsize=ceil(Nsize/N);
	xreduced=zeros(Newsize,1);

	for i=1:Newsize
		istart=1+(i-1)*N;
		istop=istart+N-1;
		if (istop > Nsize) 
			% index outside of the original vector size
			istop=Nsize;
		end
		xreduced(i)=mean(x(istart:istop)); % average of N elements
	end
end
		
