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 Comment

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.

Sign in to comment.

Answers (0)

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Asked:

on 5 Sep 2018

Commented:

dpb
on 5 Sep 2018

Community Treasure Hunt

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

Start Hunting!