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