vb 2010将数据添加到二维数组

时间:2014-04-22 02:03:07

标签: arrays vb.net

我有一个2D数组,我从10个通道(整数)收集10个样本(整数)。我可以循环并平均每个通道的样本。我需要知道如何从当前的2D数组中获取数据并填充第二个2D数组。到目前为止,这就是我所拥有的......谢谢!

      Dim data(,) As Double = reader.ReadMultiSample(10)
    Dim avgdata(,) As Double
    Dim average As Double

    For channel = data.GetLowerBound(0) To data.GetUpperBound(0)
        For samples = 0 To data.GetUpperBound(1)
            average = (data(channel, samples) + average) / samples
        Next
        avgdata.(channel, average)      'This is where I need avgdata(,) to populate new values from data(,)
    Next

这是样本数据...数据(0,0)到数据(0,4)被平均并变为avgdata(0,0)。我正在对几千个数据点进行采样,对于10个通道(20,000个数据点),一个担心的循环将非常慢。是否有一个函数来平均“内部”数组?

   data(,)                          avgdata(,)
   (0,0) = 1.3975149129757121   (0,0)=1.39802466576101
   (0,1) = 1.3975149129757121   (1,0)=1.39827949635731
   (0,2) = 1.3924173851227089   
   (0,3) = 1.3975149129757121   
   (0,4) = 1.4051612047552133   
   (1,0) = 1.3967501822575024   
   (1,1) = 1.4018478959235345   
   (1,2) = 1.3967501822575024   
   (1,3) = 1.3967501822575024   
   (1,4) = 1.3992990390905184   

0 个答案:

没有答案