function f = dfft(y) % First use standard Matlab routine to find Fourier transform of y. % z contains the complex coefficeints of the Fourier exponential series. z=fft(y); n = length(y); half=n/2; % This section takes the exponential series coefficients and gives the % coefficients of the Fourier Sine and Cosine series. % f(1) = constant term = average value of the function over period sampled % f(2) = for i = 1:2:n j=(i+1)/2; f(i)=real(z(j))/half; f(i+1)=-imag(z(j))/half; end j=n/2 +1; f(2)=real(z(j))/half;