Rectangular pulse and its Fourier transform

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,"(Subscript[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(((t - (Subscript[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]
]
}
]

This Demonstration illustrates the relationship between a rectangular pulse signal and its Fourier transform. There are three parameters that define a rectangular pulse: its height A, width T in seconds, and center (Subscript[t, 0]). Mathematically, a rectangular pulse delayed by (Subscript[t, 0]) seconds is defined as g(t-(Subscript[t, 0]))= A rect(((t-(Subscript[t, 0]))/T))=(Piecewise[{{A, (Abs[((t-(Subscript[t, 0]))/T)])≤(1/2)}, {0, otherwise}}]) and its Fourier transform or spectrum is defined as G(f)=A T sinc(π f T)exp(-i 2 π f (Subscript[t, 0])).

This Demonstration illustrates how changing g(t) affects its spectrum. Both the magnitude and phase of the spectrum are displayed.

This demonstration illustrates the following relationship between a rectangular pulse and its spectrum:

1) As the pulse becomes more flat (i.e. the width T of the pulse increases), the magnitude spectrum loops become thinner and taller. In other words, the zeros (the crossings of the magnitude spectrum with the x-axis) move closer to the origin. In the limit, as T becomes very large, the magnitude spectrum approaches a Dirac delta function located at the origin.

2) As the height of the pulse become larger and its width becomes smaller, it approaches a Dirac delta function and the magnitude spectrum flattens out and becomes a constant of magnitude 1 in the limit.

3) As (Subscript[t, 0]) changes, the pulse shifts in time, the magnitude spectrum does not change, but the phase spectrum does.

4) We notice a (180^0) phase shift at each frequency defined by (k/T) where kis an integer other than zero, and T is the pulse duration. These frequencies are the zeros of the magnitude spectrum.

Contributed by: Nasser M. Abbasi