from numpy import arange
%matplotlib inline
from matplotlib.pyplot import plot,title,xlabel,ylabel,show,figure,text
from math import sin,pi,sqrt
#Figure 1.2: Analog to Digital Conversion
t = arange(-1,1.01,0.01)
x = [2*sin((pi/2)*tt) for tt in t]
dig_data = [0,1,0,0,0,0,1,0,0,0,0,0,0,0,1,1,0,1,0,1]
figure=figure()
#a=gca()#
#a.x_location ="origin"#
#a.y_location ="origin"#
#a.data_bounds =[-2,-3#2,3]
plot(t,x)
text(0.5,sqrt(2),'gnn')
text(-0.5,-sqrt(2),'gnn')
text(1,2,'gnn')
text(-1,-2,'gnn')
xlabel(' Time')
ylabel(' Voltage')
title('Analog Waveform')
show()
plot(range(1,len(dig_data)+1),dig_data)
title('Digital Representation')
show()