# why Sampling with higher than nyquist frequency is causing aliasing?

fm=20000 and I am sampling following signal at 65000 Hz:

x=0.5*sin(2*pi*(fm-2500)*t)+0.6*sin(2*pi*(fm-1250)*t*1.05)+0.7*sin(2*pi*fm*t*1.1)+0.8*sin(2*pi*(fm+1250)*t*1.15)+0.9*sin(2*pi*(fm+2500)*t*1.2);

and looking at frequency spectrum is not as it should look like. Please find attachment. It has code and result also.

## 2 Answers

The effect you see has nothing to do with aliasing. First of all, due to spectral leakage the maxima of the spectrum do not exactly reflect the amplitudes of the sinusoids. Second, note that the DFT (implemented by the FFT) only samples the actual spectrum (the discrete-time Fourier transform, DTFT) of the signal. Depending on the choice of the sampling frequency in your example, the actual spectrum (DTFT) and the location of the sample points of the DFT shift with respect to each other, and there's no guarantee that the samples of the DFT occur at (or close to) the maxima of the actual spectrum.

You will avoid this spectral leakage by setting your t to:

t=0:1/fs:1-(1/fs)


like that you have exactly 65K samples and not 65K+1.