from Double Fourier Series Surface Plotting by Howard Wilson
Double Fourier series plots and effects of the number of terms and oscillation smoothing are shown.

c=getftcof(fun,px,py,nft)
function c=getftcof(fun,px,py,nft)
% c=getftcof(fun,px,py,nft)
% This function generates the complex Fourier
% coefficients.

% Define the grid used by FFT2
xf=linspace(0,px*(nft-1)/nft,nft);
yf=linspace(0,py*(nft-1)/nft,nft);

% Evaluate the Fourier coefficients
ft=feval(fun,xf,yf); c=fft2(ft)/nft^2;

Contact us at files@mathworks.com