Created
February 5, 2017 14:03
-
-
Save khajvahmac/12e0e8e0e77285a64d27e8bf09cd1f21 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
x = np.array([0, 0.02, 0.04, 0.06, 0.08, 0.1, 0.12, 0.14, 0.16, 0.18, 0.2]) | |
y = np.array([0, 916.6, 1968.8, 2901.2, 3671.4, 4128, 4519.6, 4773.8, 4686.2, 4281.4, 3694]) | |
z = np.polyfit(x, y, 3) | |
f = np.poly1d(z) | |
print(f) | |
#order 6 derivative | |
z_der = np.array([-5.851*3*10**5, -6.08*2*10**4, 5.418*10**4]) | |
f_der = np.poly1d(z_der) | |
x_new = np.linspace(x[0], 1, 100) | |
y_new = f(x_new) | |
y_der = f_der(x_new) | |
plt.plot(x, y, 'o', x_new, y_new) | |
#plt.plot(x_new, y_der) | |
plt.xlabel("m") | |
plt.ylabel("N") | |
plt.suptitle("Force/Deflection(m)") | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Assuming Python 3 is installed, run:
pip install numpy matplotlib
to install dependencies.To run
python spring.py