# Chapter 2: SAMPLING THEORY AND PULSE MODULATION

## Example 2.1, page no 50¶

In :
#find Nquist Rate

#Variable declaration
#given
pi=3.14
w1=50*pi
w2=300*pi
w3=100*pi
#w=2*%pi*f

#Calculation
f1=w1/(2*pi)
f2=w2/(2*pi)
f3=w3/(2*pi)
fm=f2 #fm = maximum frquency is present at the signal

#Result
print('maximum frquency of the signal is = %.2f Hz' %f2)
fs=2*fm #Nyquist rate
print('Nquist Rate of Signal is = %.2f Hz' %fs)

maximum frquency of the signal is = 150.00 Hz
Nquist Rate of Signal is = 300.00 Hz


## Example 2.2 , page no 50¶

In :
import math
#Find Nquist Rate and Nquist time interval

#Variable declaration
#given
w1=5000*math.pi
w2=3000*math.pi;
f1=w1/(2*math.pi);
f2=w2/(2*math.pi);

#Calculation
fm=f1 #fm = maximum frquency is present at the signal
fs=2*fm #Nyquist rate
Ts=1.0/(2.0*fm) #frequncy =1/time
Ts=Ts*(10**3)

#Result
print('maximum frquency of the signal is = %.f Hz' %f1)
print('Nquist Rate of the given Signal is = %.f Hz' %fs)
print('Nquist Interval of the given signal is = %.1f m Sec' %Ts)

maximum frquency of the signal is = 2500 Hz
Nquist Rate of the given Signal is = 5000 Hz
Nquist Interval of the given signal is = 0.2 m Sec


## Example 2.3, page no 51¶

In :
#Find Nquist Rate

#Variable declaration
#given
f=100.0         # Frequency component of continuous-time signal

#Calculation
fs=2*f #Nyquist rate

#Result
print('i) To avoid aliasing Nquist Rate is = %.f Hz' %fs)
print('ii) It is theoretical example ')
print('iii) It is theoretical example ')
print('iv) It is theoretical example ')

i) To avoid aliasing Nquist Rate is = 200 Hz
ii) It is theoretical example
iii) It is theoretical example
iv) It is theoretical example


## Example 2.4, page no 52¶

In :
import math
#Find Nquist Rate of Continous signal

#Variable declaration
#given
w1=50*math.pi
w2=300*math.pi
w3=100*math.pi

#Calculation
f1=w1/(2*math.pi)
f2=w2/(2*math.pi)
f3=w3/(2*math.pi)
fmax=f2 #fmax = Highest frquency component of the message signal
fs=2*fmax #Nyquist rate

#Result
print('Highest frquency component of the message signal will be fmax = %.f Hz' %fmax)
print('Nquist Rate of the given Signal is = %.f Hz' %fs)

Highest frquency component of the message signal will be fmax = 150 Hz
Nquist Rate of the given Signal is = 300 Hz


### Example 2.7, page no 67

In :
#find amplitude distortion at highest frquency

#Variable declaration
#given
fs=9.5  #samplig frequncy
fmax=1   #maximum frequncy
t=0.2 #pulse width

#Calculation
c=3*10**8
f=fmax
H1=t*(0.9933)  #aperture effect at highest frequency, sinc(f*t)=0.9933 (given)
H1=H1*100

#Result
print('|H(1)|=%.2f' %H1)
print('Approximation error')

|H(1)|=19.87
Approximation error


## Example 2.8, page no 74¶

In :
#Calculate Transmission Bandwidth

#Variable declaration
#given
fm=3.0*(10^3)
fs=8.0*(10^3) # sampling frequncy

#Calculation
Ts=1.0/fs
t=0.1*Ts
BW=1.0/(2*t) #Bandwidth
BW=BW/(10^3)

#Result
print('Transmission Bandwidth of PAM signal is kHz = %.f Khz ' %BW)

Transmission Bandwidth of PAM signal is kHz = 40 Khz