function fh = four(f,dim)
% fh = four(f)      % apply four for first dimension with size>1
% fh = four(f,dim)  % apply four for dimension dim of array f
% discrete Fourier transform
% for signal f = [f_0,...,f_{N-1}] in time domain (row or col. vector)
% find Fourier coefficients fh = [fhat_0,...,fhat_{N-1}] in frequency domain
%
% fh = four(f,dim)  % apply across dimension dim of array f
% fh = four(f,1)    % take transform of each column
% fh = four(f,2)    % take tansform of each row

if nargin==1
  dim = find(size(f)>1,1);
  if isempty(dim)
    dim = 1;
  end
end

fh = fft(f,[],dim)/size(f,dim);


