
Having troubles getting a rect function ussing fft and the sinc function
18 次查看(过去 30 天)
显示 更早的评论
As the title says I am unable to get the rect function when I fft my sinc function
Heres my code to begin with:
x = linspace(-10, 10, 10000);
y = sinc(x);
Pretty simple stuff imo.
when I do:
plot(x, y)
I get

but then when I do:
plot(x, fft(y))
I get

any help would be apprecaited
0 个评论
回答(1 个)
Star Strider
2019-4-2
编辑:Star Strider
2019-4-2
You are not plotting your Fourier transform correctly.
Try this:
x = linspace(-10, 10, 10000);
y = sinc(x);
Fs = 1/mean(diff(x)); % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
Y = fft(y)/numel(y);
Ys = fftshift(Y);
Fv = linspace(-1, 1, fix(numel(Y)))*Fn;
figure
plot(Fv, abs(Ys)*2)
grid
xlim([-5 5])
EDIT — (2 Apr 2019 at 20:09)
Added plot figure:

0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!