Implement the program for problem 2

This commit is contained in:
2023-09-08 12:46:21 +02:00
parent c256d9b1da
commit c5c64da196
2 changed files with 37 additions and 32 deletions

View File

@@ -1,17 +1,19 @@
import numpy as np
import matplotlib.pyplot as plt
x = []
y = []
v = []
with open('testdata.txt') as f:
for line in f:
a, b, c = line.strip().split()
x.append(float(a))
# y.append(float(b))
v.append(float(c))
def main():
FILENAME = "analytical_solution.pdf"
x = []
v = []
fig, ax = plt.subplots()
ax.plot(x, v)
plt.show()
# plt.savefig("main.png")
with open('analytical_solution.txt') as f:
for line in f:
a, b = line.strip().split()
x.append(float(a))
v.append(float(b))
plt.plot(x, v)
plt.savefig(FILENAME)
if __name__ == "__main__":
main()