I am developing a program to obtain numerical data for the simple harmonic oscillator. I would like to know how to save the data. For example, I want a data table with two columns: one for time (t) and one for position (x).
Below is the code I tried but was unable to save the data. Code made in idle 2.7, Python 2.6
from visual import *from visual.graph import *
m = 10; k = 10; x = 2; x1 = 0; v1 = 0; v = 0; t = 0; dt = 0.1
while(1==1):a = -(k/m)x;v += v1 + adt;x += x1 + v*dt;t = t + dt;
if t < 20:f = open(‘arq02.txt’,’w’); f.write(str(t)); f.close()
Edinardo Rodrigues is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.