MATLAB: If a fft of vector x is plotted then what would be the x-axis

fft

x=rand(1:1000)>0.5;
X=fft(x);
X_mag=abs(X);
plot(x_mag)
There would appear 1000 values in x-axis , is it frequency or what?

Best Answer

The x-axis is frequency. You can calculate it as
freqHz = (0:1:length(X_mag)-1)*Fs/N;
where Fs is your sampling rate (Hz) and N is your FFT block size (in your case N=length(x)).
You can then plot the magnitude vs frequency as
plot(freqHz,X_mag);