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 radians per second.
%
% F. J. Narcowich, Mar. 20, 2012.
%
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=2*pi/(b-a);
omega=((-N):(M))*del_omega;
phase_factor=exp(-i*a*omega);
yhat=phase_factor.*fftshift(fft(y))*(dt/sqrt(2*pi));
yhat=reshape(yhat,s);
omega=reshape(omega,s);