FFT Matlab - Meaning of Frequency Vector I'm following a tutorial about the FFT. It's well explained but I don't understand the meaning of the frequency vector:

Fs = 150; % Sampling frequency
t = 0:1/Fs:1; % Time vector of 1 second 
f = 5; % Create a sine wave of f Hz.
x = sin(2*pi*t*f); 
nfft = 1024; % Length of FFT

% Take fft, padding with zeros so that length(X) 
is equal to nfft 
X = fft(x,nfft);
% FFT is symmetric, throw away second half
X = X(1:nfft/2); 
% Take the magnitude of fft of x
mx = abs(X);
% Frequency vector
f = (0:nfft/2-1)*Fs/nfft; 

% Generate the plot, title and labels. 
figure(1);
plot(t,x);
title('Sine Wave Signal'); 
xlabel('Time (s)'); 
ylabel('Amplitude'); 
figure(2);
plot(f,mx);
title('Power Spectrum of a Sine Wave'); 
xlabel('Frequency (Hz)'); 
ylabel('Power');


Can someone explain me what is this for:

f= (0:nfft/2-1)*Fs/nfft;

Here is the link
Specifically,
nfft = 1024
Fs = 150
so f = (0:511)x(150/1024)
ie f will go from 0x(150/1024) = 0 to 511x(150/1024) = 75
So, you are plotting the magnitude of the frequency spectrum from 0 to 75 Hz.
The spectrum is periodic &amp; will repeat for 75 to 150 Hz hence you are plotting from 0 to Fs/2