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 comentario

dpb
dpb el 5 de Sept. de 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.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Fourier Analysis and Filtering en Centro de ayuda y File Exchange.

Preguntada:

el 5 de Sept. de 2018

Comentada:

dpb
el 5 de Sept. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by