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
|
# 2020-10-07:s5/sig/mm9/opg/2 #039b
import numpy as np
import matplotlib.pyplot as plt
zeros = [
[-1, 0],
[-1, 0],
[-1, 0],
]
poles = [
[0.4140, 0],
[0.5225, 0.4525],
[0.5225, -0.4525],
]
pre = 0.0317
def genHamplitude(pre, zeros, poles):
def f(omega):
vlen = lambda p: (np.sqrt((np.cos(omega) - p[0])**2 + (np.sin(omega) - p[1])**2))
top = 1
for p in zeros:
top *= vlen(p)
but = 1
for p in poles:
but *= vlen(p)
return pre * (top/but)
return f
xs = np.arange(0, np.pi, np.pi/1000)
f = genHamplitude(pre, zeros, poles)
ys = [f(x) for x in xs]
plt.plot(xs, ys)
plt.show()
|