关于本博客的说明: 本次博客主要分享快速傅里叶变换的理论相关知识及matlab提供的相关计算函数.
傅里叶变换(Fourier Transform, FT)在信号处理、物理、通信、地质学、天文学、光学等很多领域都有应用,它将一个函数或是一组数据从时域变换到频域,即傅里叶变换可以展示时间序列的频率分布情况。离散傅里叶变换(Discrete Fourier Transform, DFT)对离散信号进行处理,快速傅里叶变换(Fast Fourier Transformation, FFT)是一种高效的离散傅里叶变换方法,并且存在很多种方法来完成快速傅里叶变换。
模拟信号经过ADC采样之后,就变成了数字信号。由采样定理可知,采样频率大于信号频率的两倍时,即可对采样信号进行傅里叶变换。
一、DFT理论相关知识[1]
二、FFT理论相关知识[1]
三、MATLAB提供的相关计算函数
假设采样频率为Fs,信号频率F,采样点数为N。那么经过快速傅里叶变换之后的结果包含N个点,除第一个点外,两边呈对称分布,且为复数。每个点就对应一个频率点,这个点的模值,就是该频率下的幅值。
假设原始信号的峰值为A,经过FFT变换后,结果中每个点(第一个点的模值为直流分量的N倍)的模值就是A*N/2。第一个点表示直流分量(0Hz),第n个点所代表的频率为:Fn=(n-1)*Fs/N。
MATLAB提供了三种用于进行快速傅里叶变换的函数:
- Y=fft(X)
- Y=fft(X,n)
- Y = fft(X,n,dim)
返回n点DFT计算结果, 如果没有指定值,则Y与X的大小相同。
返回沿维度dim的傅立叶变换。 如果X是矩阵,则fft(X,n,2)返回每一行的n点傅里叶变换结果。
Examples
(备注:实例程序来自matlab 2018a提供的有关fft函数的帮助文档)% Use Fourier transforms to find the frequency components of a signal buried in noise.
% Specify the parameters of a signal with a sampling frequency of 1 kHz and a signal duration of 1.5 seconds.
Fs = 1000; % Sampling frequency
T = 1/Fs; % Sampling period
L = 1500; % Length of signal
t = (0:L-1)*T; % Time vector
% Form a signal containing a 50 Hz sinusoid of amplitude 0.7 and a 120 Hz sinusoid of amplitude 1.
S = 0.7*sin(2*pi*50*t) + sin(2*pi*120*t);
% Corrupt the signal with zero-mean white noise with a variance of 4.
X = S + 2*randn(size(t));
% Plot the noisy signal in the time domain. It is difficult to identify the frequency components by looking at the signal X(t).
plot(1000*t(1:50),X(1:50))
title('Signal Corrupted with Zero-Mean Random Noise')
xlabel('t (milliseconds)')
ylabel('X(t)')
% Compute the Fourier transform of the signal.
Y = fft(X);
% Compute the two-sided spectrum P2. Then compute the single-sided spectrum P1 based on P2 and the even-valued signal length L.
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
% Define the frequency domain f and plot the single-sided amplitude spectrum P1. The amplitudes are not exactly at 0.7 and 1, as expected, because of the added noise. On average, longer signals produce better frequency approximations.
f = Fs*(0:(L/2))/L;
plot(f,P1)
title('Single-Sided Amplitude Spectrum of X(t)')
xlabel('f (Hz)')
ylabel('|P1(f)|')
% Now, take the Fourier transform of the original, uncorrupted signal and retrieve the exact amplitudes, 0.7 and 1.0.
Y = fft(S);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
plot(f,P1)
title('Single-Sided Amplitude Spectrum of S(t)')
xlabel('f (Hz)')
ylabel('|P1(f)|')
带噪声信息的混合时域数据:
带噪声信息数据的频谱分布:
不带噪声信息的纯净信号频谱分布:
参考文献:
[1]. 王珂俨. 离散傅里叶变换(DFT)及其快速算法. http://web.xidian.edu.cn/kywang/files/20121027_164737.pdf
[2]. https://ww2.mathworks.cn/help/matlab/ref/fft.html?lang=en