function [Xk] = dft(xn,N)
%computes discrete fourier transform
%---------------------------------------------
%[Xk] = dft(xn,N)
%Xk = DFT coeff. array over 0<= k<=N-1
%xn = one period of periodic signal over 0<= n<= N-1
% N = Fundamental period of xn
%
n = [0:1:N-1];
k = [0:1:N-1];
WN = exp(-j*2*pi/N);
nk = n'*k;
WNnk = WN .^ nk;
Xk = xn * WNnk;
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
x = [1,1,1,1,zeros(1,32)];
N = 36;
X = dft(x,N);
magX = abs(X);
angleX = angle(X);
x = [1,1,1,1,zeros(1,8)];
N = 12;
X = dft(x,N);
magX = abs(X);
angleX = angle(X);