1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
{
"metadata": {
"name": "",
"signature": "sha256:5d045633a134a6b88641045e0705da6aba6d8735cb400399955dbb6bc55628cc"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Chapter 7 - Sampling Theory and Pulse modulation"
]
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 1 - pg 324"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"#calculate the nyquist rate\n",
"\n",
"import math\n",
"#given\n",
"#analog signal x(t) = 3*cos(50*math.pi*t) + 10*sin(300*math.pi*t) - cos(100*math.pi*t)\n",
"#comparing signal with x(t) = 3*cos(w_1*t) + 10*sin(w_2*t) - cos(w_3*t)\n",
"#therefore\n",
"w_1 = 50*math.pi;#first frequency in rad/sec\n",
"w_2 = 300*math.pi;#second frequency in rad/sec\n",
"w_3 = 100*math.pi;#third frequency in rad/sec\n",
"\n",
"#calculations\n",
"f_1 = w_1/(2*math.pi);#first frequency in Hz\n",
"f_2 = w_2/(2*math.pi);#second frequency in Hz\n",
"f_3 = w_3/(2*math.pi);#third frequency in Hz\n",
"f_m = f_2#maximum frequency \n",
"f_s = 2*f_m#nyquist rate for a signal\n",
"\n",
"#results\n",
"print \"Nyquist rate (Hz) = \",f_s\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Nyquist rate (Hz) = 300.0\n"
]
}
],
"prompt_number": 2
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 2 - pg 325"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"#calculate the Nyquist rate and interval\n",
"import math\n",
"#given\n",
"#x(t) = (1/()2*math.pi))*cos(4000*math.pi*t)*cos(1000*math.pi*t)\n",
"#expanding\n",
"print(\"x(t) = (1/(2*math.pi)*cos(4000*math.pi*t)*cos(1000*math.pi*t)\");\n",
"print(\"x(t) = (1/(4*math.pi)*2*cos(4000*math.pi*t)*cos(1000*math.pi*t)\");\n",
"print(\"x(t) = (1/(4*math.pi))*[cos(4000*math.pi*t + 1000*pi*t)*cos(4000*math.pi*t - 1000*math.pi*t)]\")\n",
"print(\"x(t) = (1/(4*math.pi))*[cos(5000*math.pi*t + cos(3000*math.pi*t))]\")\n",
"#by comparing above equation with x(t) = (1/(4*math.pi))*[cos(w_1*t) + cos(w_2*t)] \n",
"w_1 = 5000.*math.pi\n",
"w_2 = 3000.*math.pi\n",
"\n",
"#calculations\n",
"f_1 = w_1/(2*math.pi);\n",
"f_2 = w_2 /(2*math.pi);\n",
"f_m = f_1\n",
"f_s = 2*f_m#Nyquist rate\n",
"T_s = 1/f_s#Nyquist interval\n",
"\n",
"#results\n",
"print \"Nyquist rate (Hz) = \",f_s\n",
"print \"Nyquist interval (msec) = \",T_s*1000\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"x(t) = (1/(2*math.pi)*cos(4000*math.pi*t)*cos(1000*math.pi*t)\n",
"x(t) = (1/(4*math.pi)*2*cos(4000*math.pi*t)*cos(1000*math.pi*t)\n",
"x(t) = (1/(4*math.pi))*[cos(4000*math.pi*t + 1000*pi*t)*cos(4000*math.pi*t - 1000*math.pi*t)]\n",
"x(t) = (1/(4*math.pi))*[cos(5000*math.pi*t + cos(3000*math.pi*t))]\n",
"Nyquist rate (Hz) = 5000.0\n",
"Nyquist interval (msec) = 0.2\n"
]
}
],
"prompt_number": 9
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 3 - pg 326"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"#calculate the discrete time signal for all conditions\n",
"\n",
"#given\n",
"#x(t) = 8*cos(200*%pi*t)\n",
"f= 100.#highest frequency component of continuous time signal in hertz\n",
"f_s2 = 400.#sampling frequency in hertz for second condition\n",
"f_s3 = 400.#sampling frequency in hertz for third condition\n",
"f_s4 = 150.#sampling frequency in hertz for fourth condition since 0 < f_s4 < f_s2/2 \n",
"\n",
"#calcultions\n",
"NR = 2*f#Nyquist rate\n",
"F_1 = f/NR;\n",
"F_2 = f/f_s2;\n",
"F_3 = f/f_s3;\n",
"F_4 = f/f_s4;\n",
"f_4 = f_s4*F_4;\n",
"\n",
"#results\n",
"print \"The discrete time signal x(n) for the first condition is x(n) = 8*cos(2*pi*\",F_1,\"*n)\"\n",
"print \"the discrete time signal x(n) for the second condition is x(n) = 8*cos(2*pi*\",F_2,\"*n)\"\n",
"print \"the discrete time signal x(n) for the third condition is x(n) = 8*cos(2*pi*\",F_3,\"*n)\"\n",
"print \"The discrete time signal x(n) for the fourth condition is x(n) = 8*cos(2*pi*\",f_4,\"*t)\"\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"The discrete time signal x(n) for the first condition is x(n) = 8*cos(2*pi* 0.5 *n)\n",
"the discrete time signal x(n) for the second condition is x(n) = 8*cos(2*pi* 0.25 *n)\n",
"the discrete time signal x(n) for the third condition is x(n) = 8*cos(2*pi* 0.25 *n)\n",
"The discrete time signal x(n) for the fourth condition is x(n) = 8*cos(2*pi* 100.0 *t)\n"
]
}
],
"prompt_number": 6
},
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"Example 4 - pg 327"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"#calculate the nyquist rate\n",
"import math\n",
"#given\n",
"#x(t) = 6*cos(50*math.pi*t) + 20*sin(300*math.pi*t) - 10*cos(100*math.pi*t)\n",
"#by comparing with standard eqn x(t) = A_1*cos(w_1*t) + A_2*sin(w_2*t) + A_3*cos(w_3*t) we get \n",
"w_1 = 50*math.pi#frequency in rad/sec\n",
"w_2 =300*math.pi#frequency in rad/sec\n",
"w_3 = 100*math.pi#frequency in rad/sec\n",
"\n",
"#calculations\n",
"f_1 = w_1/(2*math.pi)#frequency in hertz\n",
"f_2 = w_2/(2*math.pi)#frequency in hertz\n",
"f_3 = w_3/(2*math.pi)#frequency in hertz\n",
"if f_1 > f_2 and f_1> f_3:\n",
" f_max = f_1\n",
"elif f_2 > f_1 and f_2> f_3:\n",
" f_max = f_2\n",
"elif f_3 > f_1 and f_3> f_2:\n",
" f_max = f_3\n",
"\n",
"f_s = 2*f_max;#nyquist rate\n",
"\n",
"#results\n",
"print \"Nyquist rate for a continuous signal (Hz) = \",f_s\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"Nyquist rate for a continuous signal (Hz) = 300.0\n"
]
}
],
"prompt_number": 5
}
],
"metadata": {}
}
]
}
|