yamid

yamid

  • NA
  • 98
  • 0

convert1D array(from a TEXT file) to 3D array

Sep 24 2008 10:00 AM

Dear all,
I wrote a program, but some thing is strange my you please just tell me why it is like this;

I have a 1-D data file ,it's order is like this
(1,1,35)
(2,1,35)
...
(76,1,35)
(1,2,35)
...
(76,2,32)
...
(76,150,35)
(76,150,34)
...
(76,150,0)

I read them to an 1D array then I tried to convert that array to a 3D rectangular array[76,150,35],
but after this conversion every thing is equal to "0" while in the 1D array alot of data are not zero:
would you please help me...
My code is as below:

private void Permx_class_data()
{
//reading the porosity data into 1D array
string path = @"C:\Documents and Settings\Desktop\example\KX";
string[] lines = File.ReadAllLines(path);
permx_data = new double[lines.Length];
PERMX = new double[76, 150, 35];
string[] temp = null;
for (int i = 0; i < lines.Length; i++)
{

temp = lines[i].Split();
permx_data[i] = double.Parse(temp[0]);

}

//changing 1D permx data into PERMX 3D array
for (int k =34; k >=0; k--)
{
for (int j = 0; j < 150; j++)
{
for (int s = 0; s < 76; s++)
{

PERMX[s, j, k] = permx_data[s + (76 * j )+ 150 *(34- k)];
Console.WriteLine(PERMX[s, j, k]);
}
}


}

}