from numpy import ones,arange,cos,sin,pi
from matplotlib.pyplot import plot,subplot,title,xlabel,ylabel,show
M =4#
i = range(0,M)
t = arange(0,0.001+1,0.001)
s1=ones([len(i),len(t)])
s2=ones([len(i),len(t)])
for i in range(0,M):
s1[i,:] = [cos(2*pi*2*tt)*cos((2*i-1)*pi/4) for tt in t]
s2[i,:] = [-sin(2*pi*2*tt)*sin((2*i-1)*pi/4) for tt in t]
S1 =[]#
S2 = []#
S = []#
m =[0,1,0,1,1,0,1,1]
for i in range(0,len(m)):
S1 = s1[m[i],:]
S2 = s2[m[i],:]
S = S+[S1*S2]
subplot(3,1,1)
plot(S1)
title('Binary PSK wave of Odd-numbered bits of input sequence')
subplot(3,1,2)
plot(S2)
title('Binary PSK wave of Even-numbered bits of input sequence')
subplot(3,1,3)
plot(S)
title('QPSK waveform')
show()
from matplotlib.pyplot import plot,subplot,title,xlabel,ylabel,show
M =4#
i = range(0,M)
t = arange(0,0.001+1,0.001)
s1=ones([len(i),len(t)])
s2=ones([len(i),len(t)])
for i in range(0,M):
s1[i,:] = [cos(2*pi*2*tt)*cos((2*i-1)*pi/4) for tt in t]
s2[i,:] = [-sin(2*pi*2*tt)*sin((2*i-1)*pi/4) for tt in t]
S1 =[]#
S2 = []#
S = []#
m =[0,1,0,1,1,0,1,1]
for i in range(0,len(m)):
S1 = s1[m[i],:]
S2 = s2[m[i],:]
S = S+[S1*S2]
subplot(3,1,1)
plot(S1)
title('Binary PSK wave of Odd-numbered bits of input sequence')
subplot(3,1,2)
plot(S2)
title('Binary PSK wave of Even-numbered bits of input sequence')
subplot(3,1,3)
plot(S)
title('QPSK waveform')
show()