(*Rectangular pulse and its Fourier transform
by Nasser M. Abbasi
version December 27 2009*)

Manipulate[
 process[a, T, t0],
 Item[Grid[{
    {
     Control[{{a, .5, "A"}, .1, maxA, .1, ImageSize -> Small, 
       Appearance -> "Labeled"}],
     Control[{{T, 50, "T"}, 1, maxT, 1, ImageSize -> Small, 
       Appearance -> "Labeled"}],
     Control[{{t0, 0, "\!\(\*SubscriptBox[\(t\), \(0\)]\)"}, -maxt0, 
       maxt0, .1, ImageSize -> Small, Appearance -> "Labeled"}]
     }
    }, Alignment -> Center, Spacings -> {0.85, 1}, Frame -> All]],
 {maxT, 100, ControlType -> None},
 {maxA, 1, ControlType -> None},
 {maxt0, 10, ControlType -> None},
 {nZeros, 5, ControlType -> None},
 FrameMargins -> 0,
 ImageMargins -> 0,
 AutorunSequencing -> {1, 2, 3},
 Initialization :>
  {
   rect[a_, T_, t0_, t_] := 
    Piecewise[{  {a, Abs[(t - t0)/T] <= (1/2)}, {0, True}}];
   
   f[a_, T_, t0_, w_] := 
    Piecewise[{{a T, 
       w == 0}, {a*T Sin[Pi w T]/(Pi w T)*Exp[-I 2 Pi w t0], True}}];
   
   
   process[a_, T_, t0_] := Module[{p1, p2, p3, w},
     
     p1 = 
      Plot[rect[a, T, t0, t], {t, (t0 - T), (t0 + T)}, 
       PlotRange -> {{-(maxT/2 + maxt0), (maxT/2 + maxt0)}, {0, 
          maxA + .1}},
       Frame -> True,
       ImagePadding -> {{44, 2}, {33, 30}},
       ImageMargins -> 5,
       ImageSize -> 300,
       AspectRatio -> .35,
       FrameTicksStyle -> Directive[10],
       AxesOrigin -> {0, 0},
       PlotStyle -> Red,
       FrameLabel -> {{Row[{Style["g", Italic], "(", 
            Style["t", Italic], ")"}], 
          None}, {Row[{Style["t", Italic], " (sec)"}], 
          Style["A rect(\!\(\*FractionBox[\(t - \*SubscriptBox[\(t\), \
\(0\)]\), \(T\)]\))", Bold]}},
       Epilog -> {{Red, Line[{{t0 - T/2, a}, {t0 - T/2, 0}}]}, {Red, 
          Line[{{t0 + T/2, a}, {t0 + T/2, 0}}]}}];
     
     p2 = Plot[Abs[Evaluate[f[a, T, t0, w]]], {w, -nZeros/T, nZeros/T},
       Frame -> True,
       AxesOrigin -> {0, 0},
       ImagePadding -> {{44, 4}, {45, 25}},
       ImageMargins -> 5,
       ImageSize -> 252,
       AspectRatio -> .5,
       PlotStyle -> Red,
       PlotRange -> {{-(nZeros/maxT), (nZeros/maxT)}, {-.1, 
          maxA*maxT + 1}},
       FrameTicks -> {{Automatic, 
          None}, {Table[i/T, {i, -nZeros, nZeros}], None}},
       FrameLabel -> {{Row[{"|", Style["G", Italic], "(", 
            Style["f", Italic], ")|"}], 
          None}, {Row[{Style["f", Italic], " (Hz)"}], 
          Style["magnitude of spectrum", Bold]}}, 
       ImagePadding -> {{40, 5}, {15, 2}}];
     
     p3 = 
      Plot[180/Pi * Arg[f[a, T, t0, w]], {w, -nZeros/T, nZeros/T}, 
       Frame -> True,
       AxesOrigin -> {0, 0},
       ImagePadding -> {{44, 4}, {45, 25}},
       ImageMargins -> 5,
       ImageSize -> 252,
       AspectRatio -> .5,
       PlotStyle -> Red,
       FrameTicksStyle -> Directive[10],
       FrameLabel -> {{"degrees", 
          None}, {Row[{Style["f", Italic], " (Hz)"}], 
          Style["phase of spectrum", Bold]}},
       PlotRange -> {{-(nZeros/maxT), (nZeros/maxT)}, {-185, 185}},
       FrameTicks -> {{{-180, -90, 0, 90, 180}, 
          None}, {Table[i/T, {i, -nZeros, nZeros}], None}}
       ];
     
     Grid[
      {
       {Item[p1, ItemSize -> Full], SpanFromLeft},
       {p2, p3}
       },
      Alignment -> Center]
     ]
   }
 ]