文章目录
对比FFT与DFT
close all;clear;clc;
f0 =60;
fs = 200;
t = 0:1/fs:20;
s = sin(2*pi*f0*t);
windowLen = 256;
s1 = s(1:windowLen);
S1 = fft(s1);
x_f = 0:fs/windowLen:fs-fs/windowLen;
F = exp(-2*pi/windowLen*(0:windowLen-1)'*(0:windowLen-1)*1i);
S2 = F*s1';
FF = dftmtx(windowLen);
S3 = FF*s1';
figure(1)
subplot(311);plot(x_f,abs(S1));title('FFT');
subplot(312);plot(x_f,abs(S2));title('DFT');
subplot(313);plot(x_f,abs(S3));title('dftmtx');