function [yhat,omega]=ft_approx(y,a,b)
% FT_APPROX computes an approximate Fourier transform from samples
% contained in the vector y. The arguments a and b are the intial
% and final times for samples to be taken. The outputs are the
% approximate Fourier transform, contained in yhat, and the
% corresponding frequencies, contained in omega. The frequencies
% are in cylces per second rather than radians per second.
%
% F. J. Narcowich, May 2, 2003.
%
s=size(y);
y=y(:).';
N=floor(length(y)/2);
if N<length(y)/2,
    M=N;
else
    M=N-1;
end
dt=(b-a)/(2*N);
del_omega=1/(b-a);
omega=((-N):(M))*del_omega;
phase_factor=exp(-i*a*omega*2*pi);
yhat=phase_factor.*fftshift(fft(y))*(dt/sqrt(2*pi));
yhat=reshape(yhat,s);
omega=reshape(omega,s);