-
Notifications
You must be signed in to change notification settings - Fork 0
/
functionB.py
70 lines (51 loc) · 1.72 KB
/
functionB.py
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
#Name:Cihat Bostancı
#ID : 150160542
import matplotlib.pyplot as plt
import numpy as np
import sys
def Mean(Signal):
return sum(Signal)/len(Signal)
def StandardDeviation(Signal):
mean = Mean(Signal)
var = sum((x-mean)*(x-mean) for x in Signal) / len(Signal) # variance
std = var**0.5
return std
def functionB(data,data2,data3,data4):
mean1 = Mean(data)
mean2 = Mean(data3)
data_norm_to_1 = [(number - mean1) / StandardDeviation(data) for number in data]
data_norm_to_2 = [(number1 - mean2) / StandardDeviation(data3) for number1 in data3]
f, (ax1, ax2) = plt.subplots(1, 2)
markerline, stemlines, baseline = ax1.stem(data2, data_norm_to_1, '-.')
plt.setp(baseline, 'color', 'r', 'linewidth', 3)
plt.ylabel("y[n]")
plt.xlabel("[n]")
plt.title("Signal Sample")
markerline, stemlines, baseline = ax2.stem(data4, data_norm_to_2, '-.')
plt.setp(baseline, 'color', 'r', 'linewidth', 3)
plt.show()
if __name__ == '__main__':
xRangeFrom = int(sys.argv[1])
xRangeTo = int(sys.argv[2])
xRangeTo = xRangeTo + 1
yRangeFrom = int(sys.argv[3])
yRangeTo = int(sys.argv[4])
yRangeTo = yRangeTo + 1
xSlice = []
x = []
ySlice = []
y = []
counter = 4
for i in range(xRangeFrom, xRangeTo):
xSlice.append(i)
counter = counter + 1
x.append(int(sys.argv[counter]))
for j in range(yRangeFrom, yRangeTo):
ySlice.append(j)
counter = counter + 1
y.append(int(sys.argv[counter]))
xnp = np.array(x)
xSlicenp = np.array(xSlice)
ynp = np.array(y)
ySlicenp = np.array(ySlice)
functionB(xnp, xSlicenp, y, ySlicenp)