% specrect.m plot the magnitude of the Fourier transform 
% of a square wave
close all 
Ts=1/100;          % time interval between adjacent samples
t=0:Ts:2e2;        % create a time vector
g=[t <= 2];        % rectangular pulse $1[0 \leq t \leq 2]$
plotspect(g,t)     % call plotspect to draw spectrum
subplot(2,1,1)
xlim([0,20])       % look only from t = 0 to t = 20 sec
subplot(2,1,2)
xlim([-2,2])       % look only from f = -2 to f = 2 Hz