private void button1_Click(object sender, EventArgs e)
{
C[0, 0] = 1;
string[] M = new string[1000000];
int i = 1, h = 0, k = 0, f = 1;
OpenFileDialog open = new OpenFileDialog();
open.Filter = "*.GFC|*.GFC";
string name = "";
if (open.ShowDialog() == DialogResult.OK)
{
name = open.FileName;
//读取原始数据
StreamReader myreader = new StreamReader(name, System.Text.Encoding.Default);
string[] split = new string[] { ","}; //这里的“,”来分隔数据读取如下区域的数据格式,总提示出错,不知道哪里有问题?求助
while ((myreader.Peek() > 0))
{
M[i] = myreader.ReadLine();
i++;
}
h = i - 1;
myreader.Close();
MessageBox.Show("共有数据" + h + "阶", "提示");
string[,] L1 = new string[h + 1, 10];
for (int j = 1; j < h + 1; j++)
{
string[] L0 = M[j].Split(split, StringSplitOptions.RemoveEmptyEntries);
for (k = 0; k < L0.Length; k++)
{
L1[j, k] = L0[k];
// richTextBox1.Text += L1[j, k] + " ";
}
// richTextBox1.Text += "\n";
// textBox1.Text = j.ToString();
}
do
{
f++;
}
while (L1[f, 0] != "end_of_head");
for (int n = 2; n < 361; n++)
{
for (int m = 0; m <= n; m++)
{
C[n, m] = double.Parse(L1[f + 2, 3]);
S[n, m] = double.Parse(L1[f + 2, 4]);
f++;
}
}
C[2, 0] -= -0.484166774985E-03;
C[4, 0] -= +0.790303733511E-06;
C[6, 0] -= -0.168724961151E-08; //调整EGM96的2-10偶数阶求函数系数
C[8, 0] -= +0.346052468394E-11;
C[10, 0] -= -0.265002225747E-14;
}
}
需要读取加载的数据格式如下:
key L M C S sigma C sigma S
end_of_head =========================================================================
gfc,0,0,1.000000000000E+00,0.000000000000E+00,0.00000000E+00,0.00000000E+00
gfc,2,0,-0.484165371736E-03,0.000000000000E+00,0.35610635E-10,0.00000000E+00
gfc,2,1,-0.186987635955E-09,0.119528012031E-08,0.10000000E-29,0.10000000E-29
gfc,2,2,0.243914352398E-05,-0.140016683654E-05,0.53739154E-10,0.54353269E-10
gfc,3,0,0.957254173792E-06,0.000000000000E+00,0.18094237E-10,0.00000000E+00
gfc,3,1,0.202998882184E-05,0.248513158716E-06,0.13965165E-09,0.13645882E-09
gfc,3,2,0.904627768605E-06,-0.619025944205E-06,0.10962329E-09,0.11182866E-09
gfc,3,3,0.721072657057E-06,0.141435626958E-05,0.95156281E-10,0.93285090E-10
我将