Why are these Fourier transform values not as expected?
Intuitively the DFT and FT are similar. As the other poster pointed out, the main difference is that sampling in the time domain is equivalent to repetition in the Frequency domain, so the DFT will have repeated spectra at multiples of the sample frequency.
Two problems here.

i) abs(real(y)) is incorrectly being used. You need the absolute value (or magnitude) of both the imaginary and real components   ... abs(y).

ii) You're seeing the effect of spectral leakage because the DFT assumes a repetitive signal; i.e. the maths "assumes" the signal you applied is repeated infinitely. Your signal will have discontinuities in this case.


Try the following code:

t = [-10*pi:pi/10:9.9*pi]
x = sin(t)
y = fft(x)
z = abs(y)


You should see this: