aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2020-10-07 16:20:28 +0200
committerJulian T <julian@jtle.dk>2020-10-07 16:20:28 +0200
commit1fd416a56ac507611e4efd0c9f54c826872095d8 (patch)
tree69b5da7788627e920814a34d1e9fa1749e5f6827
parent0df584fb0a60c72dc6205fa5bfa429dd3ea51e85 (diff)
Added signal processing assignment
-rw-r--r--sem5/sig/mm9/opg1del1.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/sem5/sig/mm9/opg1del1.py b/sem5/sig/mm9/opg1del1.py
new file mode 100644
index 0000000..d5b50d4
--- /dev/null
+++ b/sem5/sig/mm9/opg1del1.py
@@ -0,0 +1,38 @@
+# 2020-04-07:s5/sig/mm9/opg/2 #7d4a
+
+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()
+