FFT后在时域中延迟信号并在频域中进行相位更改 [英] Delay a signal in time domain with a phase change in the frequency domain after FFT

查看:1329
本文介绍了FFT后在时域中延迟信号并在频域中进行相位更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Matlab脚本中实现的基本时间/频率属性有问题. 该属性是:

I have a problem with a basic time/frequency property implemented in a Matlab script. The property is:

我试图在Matlab脚本中实现这一点. 我假设频率值为5Hz的正弦信号,采样频率等于800Hz,并且我想将此信号延迟1.8秒. 所以我实现了这个脚本:

I've tried to implement this in a Matlab script. I've supposed a sinusoidal signal with 5Hz of frequency value, Sampling frequency equal to 800Hz and I want to delay this signal by 1.8 seconds. So I've implemented this script:

Fs = 800;
Time_max = 4; % seconds
t = 0:(1/Fs):Time_max;
delay = 1.8; % One second of delay

f = 5; %Hz
y = sin(2 * pi * f * t);

figure
subplot(2,1,1)
plot(t,y);
xlabel('time (s)')
legend('Original');

%FFT
SIZE = 2^nextpow2(length(y));
Y = fft(y,SIZE);

df = Fs/SIZE;
f= -Fs/2:df:Fs/2 - df;

for k = 1:SIZE

    Y(k) = Y(k)*exp(-(1i*2*pi*f(k)*delay));

end

subplot(2,1,2)
plot(real(ifft(Y)),'r')
legend('Shifted');

输出图是:

问题出在哪里?如何获得正确的时间延迟?

Where is the problem? How can I achieve the correct time delay?

谢谢

推荐答案

问题不在实现中,而是在FFT的属性之内(分别与DFT有关):您发布的时间延迟公式是正确的,但您必须记住,您正在执行循环移位.这意味着从2.2s到4.0s的所有信号部分都将被复制到输出的开头.这正是您所看到的:

The problem is not in the implementation, but lies within the properties of the FFT (respectively of the DFT): The formula you posted for a time delay is correct, but you have to keep in mind, that it you are doing a circular shift. This means that all the signal parts from 2.2s to 4.0s will be copied to the beginning of the output. This is exactly what you see:

您想要的信号确实在1.8s处开始,但是从0到0.6837s处有一部分由于循环移位而被插入.计算量小:您的输入信号是1 x 3201,即它将用895个零进行零填充.以秒为单位,这是零的1.1187秒.循环移位将在开始时插入最后的1.8秒,即1.8-1.1187 = 0.86秒将不是零,而是包含正弦.这正是我们在图中看到的数量.

The signal you want does start at 1.8s, but from 0 to 0.6837s there is the part which is inserted due to the circular shift. Small calculation: your input signal is 1 x 3201, i.e. it will be zero-padded with 895 zeros. In seconds, this is 1.1187 seconds of zeros. The circular shift will insert the last 1.8s at the beginning, i.e. 1.8 - 1.1187 = 0.86 seconds will not be zeros but contain a sine. This is exactly the amount we see in the plot.

为避免这种影响,您必须在输入信号上至少填充零,以使信号延迟.在您的情况下,将是

To avoid this effect, you have to pad the input signal with at least the amount of zeros by which you delay the signal. In your case that would be

Fs = 800;
Time_max = 4; % seconds
t = 0:(1/Fs):Time_max;
delay = 1.8; % One second of delay

f = 5; %Hz
y = sin(2 * pi * f * t);
y = [y, zeros(1,delay*Fs)];          % Zero-pad the signal by the amount of delay

SIZE = 2^nextpow2(length(y));
Y = fft(y,SIZE);

df = Fs/SIZE;
f= -Fs/2:df:Fs/2 - df;

for k = 1:SIZE
    Y(k) = Y(k)*exp(-(1i*2*pi*f(k)*delay));
end

td = (0:SIZE-1)/Fs;
yd = real(ifft(Y));

哪个给了我们

这篇关于FFT后在时域中延迟信号并在频域中进行相位更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆