function [Xk] = dfs(xn,N)
%computes discrete fourier series coefficients
%---------------------------------------------
%[Xk] = dfs(xn,N)
%Xk = DFS 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); %w = e^((-j*2*pi*k/N)*n)
nk = n'*k; % 向左k递增 向下 n递增
WNnk = WN .^ nk; % dfs矩阵
Xk = xn * WNnk; %不同的n值相加 成为单行矩阵 只留下k参数