Can't plot Fourier Transform

Hi, I'm trying to plot the Fourier Transform of a function which is the absolute value of x from -2 to 2, here is the code:
x=-2:0.000001:2;
f_x= abs(x);
FT = fft(f_x);
f = (0:length(FT)-1)*1000/length(FT);
figure (1)
subplot(211)
plot(x,f_x), title ('f_x');
subplot(212)
plot(f,abs(FT)), ylim([0,100]), title ('Fourier f_x');
Any suggestions?

1 Kommentar

dpb
dpb am 5 Sep. 2018
Try
N=length(x);
plot(f(1:fix(N/2)+1),abs(FT(1:fix(N/2)+1))/N);
hAx.YScale='log';
Read
doc fft
example that illustrates normalizing 2-sided FFT to get one-sided PSD.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Fourier Analysis and Filtering finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 5 Sep. 2018

Kommentiert:

dpb
am 5 Sep. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by