import matplotlib.pyplot as plt import numpy as np x = np.array([0, 1.1, 2.3, 3, 4, 5, 6, 7]) # aika (s) y = np.array([0, 1.2, 4.5, 9.5, 15.2, 24.2, 37.5, 53.4]) # matka (cm) fig, ax1 = plt.subplots(1) ax1.scatter(x, y) ax1.set_xlabel("matka (cm)") ax1.set_ylabel("aika (s)") ax1.grid() a, b = np.polyfit(x*x, y, deg=1) X = np.arange(0, max(x)+1, 0.1) ax1.plot(X, a*X*X) print("kiihtyvyys:", 2*a, "cm/s²") plt.show()
kiihtyvyys: 2.1522270353221007 cm/s²