简体   繁体   中英

FFT in MATLAB producing amplitude confusion FFT of rect not making sinc

I am doing a FFT in MATLAB. As I am trying to do the FFT of a rect it does not end up being a sinc function. 在此处输入图片说明 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. 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.

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.

In your original code, FFT just considers your input signal as below.

在此处输入图片说明

Since the rect shape is little far from 0 index, your FFT is oscillated in the sinc shaped envelop with some mathematical reasons.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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