DFT 离散傅里叶变换 与 补零运算

时间:2023-02-07 12:09:54

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);

DFT 离散傅里叶变换 与 补零运算

DFT 离散傅里叶变换 与 补零运算

x = [1,1,1,1,zeros(1,8)];
N = 12;
X = dft(x,N);
magX = abs(X);
angleX = angle(X);

DFT 离散傅里叶变换 与 补零运算

DFT 离散傅里叶变换 与 补零运算