FFTアルゴリズムMATLAB実現とテスト

610 ワード

以前はFFTアルゴリズムを手動で実現したことがなく、実現した.
リファレンス
% 2012.3.10
function test
clear;
clc;
close all;
nFFT=2^10;
N=nFFT;
t=linspace(0,1,N)';
fs=N;
x=sin(2*pi*300*t);


freq=fs*((1:nFFT)-1)/nFFT;  % bug fixed 1:nFFT
figure;
disp('time[Matlab fft]:');
tic
y0=fft(x,nFFT);
toc
plot(freq,abs(y0));
title('fft');

disp('time[recursive]:');
tic
y=my_fft(x,nFFT);
toc
figure;
plot(freq,abs(y));
title('my-fft');

figure(3);
plot(freq, abs(y-y0));
title('my-fft-error');

disp('time[inplace]:');
tic
y_inplace=my_ffy_inplace(x,nFFT);
toc
figure(4);
plot