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 个评论

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.

请先登录,再进行评论。

回答(0 个)

类别

帮助中心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!

Translated by