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