Hi An,
A couple of issues with the code, addressed below.
y = [0 0 0 0 0 1 1 1 1 1 1 1 1 1 0 0 0 0];
t = [T_ech:T_ech:T_ech*length(y)];
It's a good idea to have the first point in y correspond to the sample at t = 0, athough it won't matter here because the question is about only the amplitude of the FT.
Let's plot it
So far so good. At this point, thiere is no need to normalize by n.
Looks lke we are only interested in the DFT for positive frequencies. With n an even number, the positive frequencies (assuming pi maps to a negative frequency consistent with Matlab convention) are 1:(n/2)
Because we just want to match the amplitude of the CTFT, there is no need to multiply by 2.
The frequency points, in Hz, that correspond the samples of P3 are then
f3 = 1/T_ech*(0:(n/2-1))/n;
Now the CTFT of the signal is
yy(tt) = rectangularPulse(3e-4,7e-4,tt);
YY(ww) = simplify(fourier(yy(tt),tt,ww),100)
YY(ww) =

Matlabs definiton of sinc(t) is sin(pi*t)/(pi*t). So we see that the CTFT can be expressed as
YY1(ww) = tau*sinc(ww*tau/2/pi)*exp(-1j*ww/2000)
YY1(ww) =

Verify YY1(ww) and YY(ww) are equivalent
Define a continuous frequency vector for evaluating the CTFT
f3c = linspace(0,f3(end),500);
The function Sf, computed in terms of Hz is
Now plot. Note that we have to scale the DFT by the sampling period
The reason that the plot still doesn't look like a great match is because two samples of y lie on the leading and trailing edges of the rectangular pulse. Actually, the question didn't explicitly define the underlying continuous signal, so that's an assumption on my part based on what I thought the code in the question was tyring to do. So with this assumption, we can get a much better match by treating the edge samples as 1/2
y(find(y==1,1,'last')) = 0.5;
Now we have a good match at low frequencies, but a small divergence at high frequencies. Feel free to follow up if you'd like more information about that.