function squarefig(tb,ts,fc)
tb=input('tb=')
ts=input('ts=')
fc=input('fc=')
% k=randint(1,16)
k=[0 1 0 1]
t=0:ts:tb;

pulse1=[]
pulse2=[]
y=[]
time=[]
for i=1:length(k)
    if k(i)== 0
        bit0=zeros(1,length(t))
        pulse1=[pulse1 bit0]
    elseif k(i)==1
        bit1=ones(1,length(t))
        pulse1=[pulse1  bit1]
    end
   
    if k(i)==0
        bit2=cos(2*pi*fc*t)
        pulse2=[pulse2 bit2]
    elseif k(i)==1
        bit3=-cos(2*pi*fc*t)
        pulse2=[pulse2  bit3]
       
    end 
       
   y=[y cos(2*pi*fc*t)]    
time=[time t]
t=t+tb
end
subplot(3,1,1)
plot(time,pulse1)
subplot(3,1,2)
plot(time,pulse2)

subplot(3,1,3)
plot(time,y)

axis([0 8 -3 3])