FFT(Fast Fourier Transform),即快速傅里叶变换。IFFT(Inverse Fast Fourier Transform),即逆傅里叶变换。本文想要跟大家一起探讨的一个无聊的问题是,假如你有一个FFT函数,如何利用这个FFT函数来做IFFT计算,而不是直接使用IFFT函数。
首先来看FFT是怎么计算的:
其中,k为频域信号X的索引,n为时域信号x的索引,N为FFT点数,又称为旋转因子。
然后来看一下IFFT是怎么计算的:
其中,k为时域信号X的索引,n为频域信号x的索引,可以看到,其实IFFT和FFT的差异其实只是旋转因子不一样,FFT的复指数的指数是负的,而IFFT的复指数的指数是正的。这个差异可以通过以下的变换对消:
conj()表示取共轭。下面直接上代码:
clc;
clear;
% Define the number of samples (N)
N = 8;
% Example input signal (time-domain signal)
x = [1, 2, 3, 4, 5, 6, 7, 8];
% Step 1: Perform the FFT of the input signal
X = fft(x);
% Step 2: Perform the FFT of the conjugate of the FFT result (to simulate IFFT)
X_conj = fft(conj(X)); % Apply FFT to the conjugate of the FFT result
% Step 3: Take the conjugate of the FFT result
ifft_result = conj(X_conj);
% Step 4: Normalize the result by dividing by N (to scale the IFFT output)
ifft_result = ifft_result / N;
% Display the original signal and IFFT result
disp('Original Signal:');
disp(x);
disp('IFFT Result (computed using FFT twice and other operations):');
disp(ifft_result);
代码的运行结果如下: