function [a,b] = dft (y) % DFT - The Discrete Fourier Transform % [a, b] = DFT (y) % a, b are the cosine and sine components % for j = 0, 1, ..., n/2 n = length (y); n2 = floor (n / 2); a = zeros (1,n2+1); b = zeros (1,n2+1); t = 2*pi*(0:n-1)/n; f = 2.0 / n; for j = 0:n2 cs = cos (j * t); ss = sin (j * t); a(j+1) = f * (cs * y); b(j+1) = f * (ss * y); end a(1) = 0.5 * a(1); a(n2+1) = 0.5 * a(n2+1); b(1) = 0.0; b(n2+1) = 0.0;