why we need to multiply x axis with SAmpling frequency and divide it by length of FFT

13 次查看(过去 30 天)

Im new to matlab im doing a simple FIR design i got stuck at particularly one line that is
nfft = 2.^nextpow2(length(x));
fy = fft(x,nfft);
fy = fy(1:nfft/2);

xfft = Fs*(0:nfft/2-1)/nfft;%why????????????

plot(xfft,abs(fy/max(fy)));

% Im not getting why xfft is calculated in that way sombody please help!!

  1 个评论
cr
cr 2022-12-1
编辑:cr 2022-12-1
Remove the multiplication and division and see what you get. Try and interpret the result. Introduce the multiplication and division one at a time and see how it affects the result. #joyoflearning

请先登录,再进行评论。

回答(1 个)

V Sairam Reddy
V Sairam Reddy 2022-12-8
Hi Abhay,
I understand that you want to know why Fs/N is being multiplied to the X-axis.
Here are some things to help you understand:
  • The number of points in the time domain equals to number of points in frequency domain which is N.
  • The FFT shows frequency domain view of time domain signal in frequency space of -Fs/2 to Fs/2.
  • This frequency space is split into N equally spaced points leading to a gap of Fs/N between the consecutive points.
  • That means, if a frequency component is at freq=0, the next component will be at freq=1*Fs/N, the next will be at freq=2*Fs/N, and it goes on till (N-1)*Fs/N.
  • The frequency spectrum is periodic, hence all the components from [-Fs/2, 0] are again repeated in [Fs/2, Fs].
  • The FFT function gives the positive frequency components first and then the symmetric negative frequency components making the frequency range [0, Fs]. Hence, we only consider first half of the spectrum.
  • Hence the X-axis corresponds to the frequencies and the Y-axis corresponds to the magnitude of that corresponding frequency present in the signal.
Hope this helps you understand. Please refer to this MATLAB Answer - If a fft of vector x is plotted then what would be the x-axis? to get some more insights.

类别

Help CenterFile 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