From 1fd416a56ac507611e4efd0c9f54c826872095d8 Mon Sep 17 00:00:00 2001 From: Julian T Date: Wed, 7 Oct 2020 16:20:28 +0200 Subject: Added signal processing assignment --- sem5/sig/mm9/opg1del1.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 sem5/sig/mm9/opg1del1.py (limited to 'sem5/sig') 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() + -- cgit v1.2.3