471,887 Members | 1,247 Online

# Combine (2) Arrays into a Single Average Array

I know have (2) seperate arrays that hold an undefined number of information. I would like to take array-1 and array-2 and create an average array between the two

array1 array2 arrayAVG
4096 4095 4095.5
4071 4012 4041.5
4000 3812 3906

This would be the idea of how i wnat it, then i would take the arrayAVG and write to a file.
Sep 6 '07 #1
2 2116
1,295 Expert 1GB
just create it
if array1 and array2 have the same number of elements and the same indexes, something like this will help:

Expand|Select|Wrap|Line Numbers
1. dim i as integer
2. dim arrayAV() as double
3.
4. redim arrayAV(lbound(array1) to ubound(array1))
5.
6. for i = lbound(array1) to ubound(array1)
7.     arrayAV(i)= (array1(i) + array2(i) )/2
8. next
hth
Sep 6 '07 #2
Hi,

I created a sample program for you that might help you combine two or more arrays in 1 single array.. you can use this program as a pattern.

Dim x1(2) As String
Dim x2(2) As String
Dim x3(2) As String
Dim i As Integer = 0

For i = 0 To 2
x1(i) = "FName_" & i
x2(i) = "MName_" & i
x3(i) = "LName_" & i
Next

Dim xCombined(8) As String
x1.CopyTo(xCombined, 0)
x2.CopyTo(xCombined, 3)
x3.CopyTo(xCombined, 6)

I know have (2) seperate arrays that hold an undefined number of information. I would like to take array-1 and array-2 and create an average array between the two

array1 array2 arrayAVG
4096 4095 4095.5
4071 4012 4041.5
4000 3812 3906

This would be the idea of how i wnat it, then i would take the arrayAVG and write to a file.
Sep 7 '07 #3