简体   繁体   English

fft / ifft:采样频率和信号长度

[英]fft/ifft: Sampling Frequency and Length of Signal

This is partly taken from the Matlab fft-documentation: 这部分来自Matlab fft文档:

Fs = 30;                    % Sampling frequency
T = 1/Fs;                   % Sample time
L = 130;                    % Length of signal
t = (0:L-1)*T;              % Time vector

x = sin(2*pi*1*t);          % 1 Hz sinus

plot(real(ifft(abs(fft(x))))); % fft then ifft

% Fs = 30, L = 60 / 90 / 120 ... : ok
% Fs = 20, L = 60 / 80 / 100 ... : ok
% Fs = 30, L = 50 / 70 / 80 ... : not ok

It seems to me that whenever the length of the signal is a multiple of the sampling frequency, the sinusoid is reconstructed correctly (apart from some shift), eg here Fs = 30, L = 60 : 在我看来,只要信号的长度是采样频率的倍数,正弦曲线就会被正确地重建(除了一些移位),例如这里Fs = 30, L = 60

在此输入图像描述

However, if for example Fs = 30, L = 80 (not a multiple), the result looks odd: 但是,如果例如Fs = 30, L = 80 (不是倍数),则结果看起来很奇怪:

在此输入图像描述

Is this behaviour correct? 这种行为是否正确? Why is this happening and how can I avoid this? 为什么会发生这种情况,我该如何避免这种情况? Just throw away some part of the signal such that the length "fits" the sampling frequency? 只是扔掉信号的某些部分,使长度“适合”采样频率?

When you use the abs(fft()) in ifft, you are using only the amplitude of the signal and dropping the phase information, which is needed. 当你在ifft中使用abs(fft())时,你只使用信号的幅度并丢弃所需的相位信息。

Use the whole signal (removed abs): 使用整个信号(删除abs):

plot(real(ifft(fft(x)))); % fft then ifft

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM