aboutsummaryrefslogtreecommitdiffstats
path: root/lab2/scripts/filter.py
blob: c35f75eaba13e83cc5ea31f7cd219ee429e2e899 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from math import sqrt
import matplotlib.pyplot as plt


a0 = sqrt(2)
b0 = 1/sqrt(2)

y = [0, 0, 0]
x = [1]

result = [0]

for i in range(0, 8):
    y[0] = a0 * y[1] - y[2] + b0 * x[0]
    result.append(y[0])
    y[2] = y[1]
    y[1] = y[0]
    x[0] = 0

plt.plot(result)
plt.title("Filter Output")
plt.ylabel("y: sin(x)")
plt.xlabel("x: sample")
plt.show()