Unknown line in code

2 views (last 30 days)
Bruce Pollom
Bruce Pollom on 3 Jan 2018
Answered: Star Strider on 3 Jan 2018
% P0=90;
% Ps=10000;
% Ts=1/Ps;
% t=0:Ts:0.4;
% w0=2*pi*F0;
% A=2;
% x=A*sin(w0*t)
%
% Nfft=length(x)*32;
% x=fft(x,Nfft);
% x=fftshift(x);
% F=-Fs/2:Fs/Nfft:Fs/2-Fs/Nfft;
%
In the code above, what is the point of this line ? : " % F=-Fs/2:Fs/Nfft:Fs/2-Fs/Nfft; "

Accepted Answer

Star Strider
Star Strider on 3 Jan 2018
This line:
F=-Fs/2:Fs/Nfft:Fs/2-Fs/Nfft;
defines the frequency vector for a two-sided fft, where 0 Hz is in the centre of the plot. Here, ‘Fs’ is the sampling frequency, undefined in the code you posted (but is probably 1/Ts).

More Answers (0)

Categories

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

Tags

Community Treasure Hunt

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

Start Hunting!