Why does the frequency in the DFT have to be an integer?
There are a few different ways to interpret the math of the DFT. The one I find most suitable to explain this and other properties of the DFT assumes that the continuous Fourier domain was sampled, which causes the time domain to become periodic (just like the signal was sampled, causing the Fourier domain to become periodic).

If your signal contains a sine wave, it has a single frequency. But if a non-integer number of periods of this sine wave is represented by the samples in your discrete signal, then there will be a discontinuity when replicating these samples. This discontinuity contains all frequencies.

The "frequency" parameter used in the DFT, often represented as k, is in relation to the length of the signal. If your signal shows exactly a single period of the sine wave, this sine wave has a frequency k=1. If you see exactly two periods, it has a frequency k=2. If you see one and a half periods, then k would be 1.5, which does not exist.

Draw one and a half period of a sine wave. Now copy that signal multiple times end to end:



x = cos(linspace(0,3*pi,1000));
plot(repmat(x,1,7))
set(gca,'xticklabel',0:7)




You now have a signal where the lowest frequency corresponds to the repetition of the original signal, the period length is the length of the original signal. This is k=1. The next frequency is twice this lowest frequency (period is half). You will notice if you study the graph above that there is nothing that repeats with a frequency of 1.5 times the lowest frequency (period is 1.5 times the original signal). Such a frequency does not exist because of how the signal was constructed.