# Why dft sine plot is so strange

Why does my dft plot of $$\sin(x)$$ look so strange? It goes to negative and then inverts closer to the edge.

x=0:0.1:10;
N=max(size(x));
y=sin(x);
plot(fftshift(real(fft(y)/N)));


• imho you need to change real to abs Nov 4, 2023 at 17:14
• i tried it helped fix the part of negative interval but that doesn't make any change to the peak: imgur.com/a/b9vFRWt Nov 4, 2023 at 17:30
• it is need tapering beginning and end of the signal or make integer value for number of periods, mathworks.com/help/signal/ug/windows.html Nov 4, 2023 at 18:19
• thank you! i think i get the idea Nov 4, 2023 at 18:27

If you want to see a sharp peak at frequency $$\omega = 1$$, as in the code in your question, then you need to increase the DFT resolution by increasing the number of samples in the signal. With x = 0:0.1:100, I get:
If you want to see a sharp peak without increasing the number of samples, you need to increase the signal's frequency. With y = sin(10*x) I get:
Note that in both cases what has been done is to increase the number of sine periods in the signal y. This is the key to obtaining a high-resolution spectrum using the DFT.