MATLAB: Is this code saying i have a wave at 2 KHz and 6Khz?

fft

freq_HZ = 2000; % Define the frequency in Hertz
freq_RPS = 2*pi*freq_HZ; % Compute the frequency in rad/sec
t = 0:1/8000:5; % Define the time vector
y = sin(freq_RPS * t);
f = (0:length(y)-1)*8000/length(y);
plot(f,abs(fft(y)))

Best Answer

For real only time signals, the FFT is only meaningful up to fs/2 where fs is the sampling frequency.
For real only time signals the 2nd half of the FFT is just a mirror.
Since you are defining the time vector with
t = 0:1/8000:5;
the sampling frequency you are using is the inverse of the time step
fs=1/8000
Just use the FFT up to 4kHz plotting the lower half of frequencies
would you please be so kind to mark my answer as accepted?
John BG