b = [0, 23, 62, 8, 43, 16, 71, 47, 19, 61]
f9 = [0,0,0,0,0,0,0,0,0,0]
for i in range(10):
f9[i] = b[i]+9+2
if f9[i]>79:
f9[i] = f9[i]-79
print 'For i = %i ,(bi) = %i. Therefore.f9%i) = [%i+9]mod79)+2 = %i'%(i,b[i],i,b[i],f9[i])
# Variables
fd = .160; #in MHz
Fc = 2411;
# Calculations and Results
print 'a)fd = %.2f MHz. a 0 is represented by %.2f MHz'%(fd,Fc-fd)
print 'b)A 1 is represented by %.2f MHz'%(Fc+fd)
# Variables
fd1 = .216; #in MHz
fd2 = .072; #in MHz
Fc = 2400+25 ; #MHz
# Calculations and Results
print 'a)fd1 = %.2f MHz. a 00 is represented by %.3f MHz'%(fd1,Fc-fd1)
print 'b)A 01 is represented by %.3f MHz'%(Fc-fd2)
print 'c)A 10 is represented by %.3f MHz'%(Fc+fd1)
print 'b)A 11 is represented by %.3f MHz'%(Fc+fd2)
#answer in part a is misprinted in the text
%matplotlib inline
from numpy import zeros,concatenate,array,arange,ones,linspace,sin
from matplotlib.pyplot import plot,suptitle,xlabel,ylabel,subplot
import math
code = array([0, 1, 0, 1, 1, 0]);
t = arange(0,2.01,0.01) #for x-axis
a = sin(2*math.pi*t) #for y-axis
y = []
x = []
for i in range(len(code)):
if code[i] == 1:
a = -a;
y = concatenate((y, a))
x = concatenate((x, 2*math.pi*(t+2*(i-1))))
plot(x,y)
suptitle('DPSK used to encode 010110')
xlabel('Time')
ylabel('amplitude')
%matplotlib inline
from numpy import zeros,concatenate,array,arange,ones,linspace,sin
from matplotlib.pyplot import plot,suptitle,xlabel,ylabel,subplot
import math
code = array([0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1]);
t = arange(0,2.01,.01) #for x-axis
y = []
x = []
p = 0 #phase shift
for i in range(0,len(code),2):
if code[i] == 0:
if code[i+1] == 0:
p = p+0
else:
p = p+math.pi/2
else:
if code[i+1] == 1:
p = p+math.pi
else:
p = p+3*math.pi/2
y = concatenate((y, sin(2*math.pi*t+p)));
x = concatenate((x, 2*math.pi*(t+(i-1))));
plot(x,y);
suptitle('DQPSK used to encode 001110000001')
xlabel('Time')
ylabel('amplitude');