function y = wfilter(x,f)
% Simple function that takes in the signal x and filter boundaries f = [f1 f2]
% and returns the filtered signal y. The algorithm is to take the DFT of x,
% setting all cofficients outside the limits to zero and return the
% inverse-transformed y
%
%				Henrik Manum, may 2006 (Pisa)

% if length(x) ~= 4096
% 	error('Until now the length of the signal needs to be 4096')
% end

N = length(x);

y = fft(x,N);
k = [floor(f(1)*N + 1) ceil(f(2)*N+1)];
y(1:k(1)-1) = 0 ;
y(k(2)+1:(N+2-k(2)-1)) = 0;
y(N+2-k(1)+1:end)=0;
p = abs(y)/(N/2);
p = p(1:N/2).^2;
% freq = [0:1/(N-1):1];
freq = [0:N/2 - 1]/N;
plot(freq,p);

y = ifft(y);

return
	
