It sounds like you need to some background reading on what an FFT is (e.g. http://en.wikipedia.org/wiki/FFT). But to answer your questions:
Why does the x-axis (frequency) end at 500?
Because the input vector is length 1000. In general, the FFT of a length-N
input waveform will result in a length-N
output vector. If the input waveform is real, then the output will be symmetrical, so the first 501 points are sufficient.
Edit: (I didn't notice that the example padded the time-domain vector.)
The frequency goes to 500 Hz because the time-domain waveform is declared to have a sample-rate of 1 kHz. The Nyquist sampling theorem dictates that a signal with sample-rate fs
can support a (real) signal with a maximum bandwidth of fs/2
.
How do I know the frequencies are between 0 and 500?
See above.
Shouldn't the FFT tell me, in which limits the frequencies are?
No.
Does the FFT only return the amplitude value without the frequency?
The FFT simply assigns an amplitude (and phase) to every frequency bin.