-
Notifications
You must be signed in to change notification settings - Fork 0
/
SIMPSON-EXCEL.py
57 lines (48 loc) · 2.12 KB
/
SIMPSON-EXCEL.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
import matplotlib.pyplot as plt
from openpyxl import Workbook, load_workbook
from openpyxl.utils import get_column_letter
def simpson(a = 3, b = 40982, wb = load_workbook('SPEED.xlsx')):
ws = wb.active
Resultado_suma = 0
Delta_x = 0
Resultado_final = 0
for row in range(a, b):
if row % 2 == 1:
for col in [2]:
char = get_column_letter(col)
Resultado_suma += (ws[char + str(row)].value) * 4
else:
for col in [2]:
char = get_column_letter(col)
Resultado_suma += (ws[char + str(row)].value) * 2
Resultado_suma += ws["B2"].value + ws["B40981"].value
Delta_x = (ws["A40981"].value - ws["A2"].value) / 40980
Resultado_final = (Resultado_suma * Delta_x) / 3
print(Resultado_final)
Redondear = round(Resultado_final, 2)
return Redondear
def graficar_S(x = [], y = [], wb = load_workbook('SPEED.xlsx'), a = 3, b = 40982):
ws = wb.active
for row in range(a, b):
for col in [2]:
char = get_column_letter(col)
y.append(ws[char + str(row)].value)
for col in [1]:
char = get_column_letter(col)
x.append(ws[char + str(row)].value)
plt.plot(x, y, color = "black")
plt.title(f"Velocidad del automóvil a lo largo de todo el viaje {simpson()}")
plt.xlabel("Tiempo t(s)")
plt.ylabel("Velocidad v(m/s)")
plt.fill_between(x, y, color = (232/255, 238/255, 249/255))
plt.show()
graficar_S()
"""
⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣶⣄⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⢀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣦⣄⣀⡀⣠⣾⡇⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀
⠀⠀⠀⠀⢀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠿⢿⣿⣿⡇⠀⠀⠀⠀
⠀⣶⣿⣦⣜⣿⣿⣿⡟⠻⣿⣿⣿⣿⣿⣿⣿⡿⢿⡏⣴⣺⣦⣙⣿⣷⣄⠀⠀⠀
⠀⣯⡇⣻⣿⣿⣿⣿⣷⣾⣿⣬⣥⣭⣽⣿⣿⣧⣼⡇⣯⣇⣹⣿⣿⣿⣿⣧⠀⠀
⠀⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠸⣿⣿⣿⣿⣿⣿⣿⣷⠀
"""