Chapter 3 : Analysis and transmission of signals

Page no 75 Prob 3.1

In [5]:
from scipy.fftpack import fft
from math import exp
# given signal is x(t)= e**(-at) * u(t)
#unity function u(t)=1 for 0 to infinity 
#therefore
x=1#
#here we consider 'infinity' value as 10 and the value of 'a' is 1
t= range(0,11)
a=1## a >0
z=[]
for tt in t:z.append((exp(-a*tt) * x))
y=fft(z)#
print 'fourier transform of x(t)=:\n',y
fourier transform of x(t)=:
[ 1.58195029+0.j          1.33722176-0.38516024j  1.02105993-0.4033185j
  0.84862839-0.29364174j  0.76732853-0.17191927j  0.73478625-0.05628763j
  0.73478625+0.05628763j  0.76732853+0.17191927j  0.84862839+0.29364174j
  1.02105993+0.4033185j   1.33722176+0.38516024j]

Page no 81 Prob 3.2

In [10]:
from scipy.fftpack import fft

#given signal is x(t) = rect(t/T)
#rect(t/T) = 1 for |t| < T/2  and   
#          = 0 for |t| > T/2
# therefore we have to find out fourier transform of x(t)= 1 for |t| < T/2 thus,
x=[1]#
T= 200# # consider 
t= range(-T/2,T/2+1)##range for fourer transform
y=fft(x)#
print 'fourier transform of x(t)=:\n',y
fourier transform of x(t)=:
[ 1.+0.j]

Page no 82 Prob 3.3

In [12]:
from scipy.fftpack import fft

# given signal is x(t)= unit impulse d(t) 
#it is defined as d(t) = 1 for t=0
#therefore 
x=1#
y=fft([x])#
print 'fourier transform of x(t)=:\n',y
fourier transform of x(t)=:
[ 1.+0.j]

Page 84 problem 3.7

In [14]:
from numpy import sign
t=range(-10,11)#
y=sign(t)#
g=fft(y)#
print "fourier transform of signum funcion is : \n",g
fourier transform of signum funcion is : 
[ 0.00000000 +0.j         -1.98883083+13.19503037j -0.04442719 +0.14402943j
 -1.90096887 +3.94740253j -0.17376123 +0.25486091j -1.73305187 +1.86778571j
 -0.37651020 +0.30025686j -1.50000000 +0.8660254j  -0.63465898 +0.24908529j
 -1.22252093 +0.27903243j -0.92526991 +0.06933939j -0.92526991 -0.06933939j
 -1.22252093 -0.27903243j -0.63465898 -0.24908529j -1.50000000 -0.8660254j
 -0.37651020 -0.30025686j -1.73305187 -1.86778571j -0.17376123 -0.25486091j
 -1.90096887 -3.94740253j -0.04442719 -0.14402943j -1.98883083-13.19503037j]