Having troubles getting a rect function ussing fft and the sinc function

18 vues (au cours des 30 derniers jours)
Pouya Tavakoli
Pouya Tavakoli le 2 Avr 2019
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
sinc.jpg
but then when I do:
plot(x, fft(y))
I get
fft.jpg
any help would be apprecaited

Réponses (1)

Star Strider
Star Strider le 2 Avr 2019
Modifié(e) : Star Strider le 2 Avr 2019
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:
Having troubles getting a rect function ussing fft and the sinc function- 2019 04 02.png

Catégories

En savoir plus sur Fourier Analysis and Filtering dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by