简体   繁体   English

MATLAB中的FFT产生幅度混淆rect的FFT不产生正弦

[英]FFT in MATLAB producing amplitude confusion FFT of rect not making sinc

I am doing a FFT in MATLAB. 我在MATLAB中执行FFT。 As I am trying to do the FFT of a rect it does not end up being a sinc function. 当我尝试执行rect的FFT运算时,它最终不会成为Sinc函数。 在此处输入图片说明 instead when I try to correct the error I get 相反,当我尝试纠正错误时,我得到了 在此处输入图片说明 This correction of using abs I have seen all over the internet but it does not create the sinc function. 我在互联网上已经看到过使用abs的这种纠正方法,但是它并不能创建sinc函数。 Here is all the code that I am using. 这是我正在使用的所有代码。

x = linspace(-15,15,257);
x = x(1:256);
y = rectangularPulse(x)
plot(x,y)
Y = fft(y);
plot(x, fftshift(abs(Y)))

Any help would be greatly appreciated. 任何帮助将不胜感激。

Thanks, 谢谢,

T Ť

FFT doesn't care x-axis of your input signal. FFT不在乎输入信号的x轴。

Just, change your code like below. 只是,如下更改您的代码。

x = linspace(0,30,257);
y = rectangularPulse(x)
figure(1)
plot(y)
Y = fft(y);
figure(2)
plot(fftshift(real(Y)))

With this code, you can see sinc function after fft. 使用此代码,您可以在fft之后看到sinc函数。

In your original code, FFT just considers your input signal as below. 在您的原始代码中,FFT仅考虑您的输入信号,如下所示。

在此处输入图片说明

Since the rect shape is little far from 0 index, your FFT is oscillated in the sinc shaped envelop with some mathematical reasons. 由于rect形状与0索引相差很小,因此由于某些数学原因,FFT在sinc形状的包络中振荡。

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

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