469,159 Members | 1,482 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,159 developers. It's quick & easy.

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 2073
kadghar
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

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

13 posts views Thread by Ben | last post: by
9 posts views Thread by Charles Banas | last post: by
8 posts views Thread by frekster | last post: by
3 posts views Thread by Schroeder, AJ | last post: by
8 posts views Thread by RobcPettit | last post: by
5 posts views Thread by nelly0 | last post: by
5 posts views Thread by jc | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.