Hi guys(adsbygoogle = window.adsbygoogle || []).push({});

I've done a Runge-Kutta script for the Lorenz Equations in python, I need to write data for (t,x,y,z) in a .dat file in order to reprint in a table. How can a do it?

Imported routines are:

import sys, pylab, numpy

from pylab import *

from mpl_toolkits.mplot3d import Axes3D

from numpy import *

import matplotlib.pyplot as plt

Mi iteration code is:

for n in xrange(0,N):

# at each time step calculate new x(t),y(t),z(t)

# and append to lists x0, y0, z0

x,y,z = RKTwoD(x0[n],y0[n],z0[n],VDPXDot,VDPYDot,VDPZDot,dt)

x0.append(x)

y0.append(y)

z0.append(z)

t.append(t[n] + dt)

savetxt('output.dat', (t,x0,y0,z0))

But it doesn't work, file just contain six columns instead of four and it takes too long to execute the script.

Please can anyone help me?

Thank you

**Physics Forums - The Fusion of Science and Community**

# How to write a data file in Python

Have something to add?

- Similar discussions for: How to write a data file in Python

Loading...

**Physics Forums - The Fusion of Science and Community**