function   DATA = freqfiltXT(a,X)

%   this func reads the input trace (curve, in a), w/length N, and filters
%   it to keep only those frequences specified by X.  X is an array of 
%   integers in [1,N], of which "1" corresponds to the slowest change, i.e.
%   constant, and "N" corresponds to fastest change, i.e. T=N/(N-1).
%                                                    -102705XT

b= fft(a);
realrescore = (real(b(X)))';
imagrescore = (imag(b(X)))';

temps = size(X);
N = temps(2);
if temps ~= [1  N]
      error ('input X in wrong dimension! ')
end

temps = size(a);
N = temps(2);
if temps ~= [1  N]
      error ('input trace in wrong dimension! ')
end

for i = 1:N
    DATA(i) = cos((i-1)*(X-1)*2*pi/N) * realrescore /N   -   sin((i-1)*(X-1)*2*pi/N)  * imagrescore /N;
end

%plot 
figure,  plot(DATA)