# 1D arrays

1D arrays in DataMelt are designed for numerical calculations and are optimized for numbers. We first consider  P0D arrays (to hold double values) and  P0I (to hold integer values)

<jc lang="dmelt"> from jhplot import P0D p0=P0D("test") for i in range(10):

     p0.add(i)


print p0.toString() </jc>

One can view the data containers using several methods. One is toString() which converts data into a string. One can write data into a file (including a compression) using the method toFile(file). One can also view data in a sortable table using the method toTable():

<jc lang="dmelt"> from jhplot import P0D p0=P0D("test") for i in range(1,50,2):

     p0.add(i)


p0.toTable() </jc>

As for any DataMelt data object, one can write and read arrays into files using the method "toFile" and read using the method "read()"

p0.toFile("data.txt")

p0.read("data.txt")

If a file was zipped use the method "readZip()".

One can access various statistical characteristics of the P0D arrays as:

<jc dmelt member_edit> from jhplot import P0D p0=P0D("test") for i in range(1,50,2):

     p0.add(i)


print p0.getStatString() </jc> <fc #008000>Exercise: try to increase the number of iteration to 1000 and see the output. </jnote>

# 2D arrays

2D arrays are based on the Java class  P1D. This class can be used to show data in X-Y plane As before, one can fill such arrays using the method "add(x,y)".

Here is a simple example how to show several data sets on on X-Y graph: <jc lang="dmelt"> from jhplot import P1D, HPlot from java.awt import Color

c1 = HPlot("Canvas") c1.visible() c1.setAutoRange() c1.draw(p1); c1.draw(p2) </jc>

# N-dimensional arrays

<ifauth ns="learn">