% specsquare.m plot the spectrum of a square wave
close all
f0=10;                  % "(fundamental) frequency" of the square wave
EndTime=2;              % Will consider from time = 0 to EndTime
Ts=1/1000;              % sampling interval (time interval between samples)
t=0:Ts:(EndTime-Ts);    % create a time vector
x=sign(cos(2*pi*f0*t)); % square wave = sign of cos wave
plotspect(x,t)          % call plotspec to draw spectrum