MATLAB: Is there an error with the example for FFT in the MATLAB 7.6 (R2008a) documentation

MATLAB

The example code for FFT in the documentation is not correct. While the example follows the correct general method for finding the frequency components of a signal, to ensure mathematically correct results, the code should be changed from:
f = Fs/2*linspace(0,1,NFFT/2);
plot(f,2*abs(Y(1:NFFT/2)))
to
f = Fs/2*linspace(0,1,NFFT/2+1);
plot(f,2*abs(Y(1:NFFT/2+1)))

Best Answer

This change has been incorporated into the documentation in Release 2009a (R2009a). For previous releases, read below for any additional information:
This is a bug in the documentation for FFT in MATLAB 7.6 (R2008a)
When using the example, use the corrected code:
f = Fs/2*linspace(0,1,NFFT/2+1);
plot(f,2*abs(Y(1:NFFT/2+1)))