【发布时间】:2012-04-27 01:44:33
【问题描述】:
我被要求在 matlab 中编写一个 fft 混合基数,但在此之前,我想让以直接的方式进行离散傅立叶变换。所以我决定按照维基百科定义的公式来写代码。
[抱歉,我还不能发布图片]
http://en.wikipedia.org/wiki/Discrete_Fourier_transform
所以我写了如下代码:
%Brutal Force Descrete Fourier Trnasform
function [] = dft(X)
%Get the size of A
NN=size(X);
N=NN(2);
%====================
%Declaring an array to store the output variable
Y = zeros (1, N)
%=========================================
for k = 0 : (N-1)
st = 0; %the dummy in the summation is zero before we add
for n = 0 : (N-1)
t = X(n+1)*exp(-1i*2*pi*k*n/N);
st = st + t;
end
Y(k+1) = st;
end
Y
%=============================================
但是,我的代码输出的结果似乎与本网站的结果不同: http://www.random-science-tools.com/maths/FFT.htm
您能帮我找出问题所在吗?
谢谢!
============ 没关系,我的代码似乎是正确的......
【问题讨论】: