LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

2D array continous summation

Solved!
Go to solution

hey all,

 

I am looking in making a labview program to continuously sum the elements of a 2D array

for example,

lets say the first array is [ 1  1  1  ]

then the second is [  2   2   2  ]

i need the result to be [  3   3   3  ]

i know how to do it up to here but the tricky part is that if the third array comes [  4   4   4  ]

i need the result to be [  7   7   7  ]

so it continously summing the arrays for a very long time.

so i need the previous array to become the starting point for the following array and sum and the result of that array summed with a new array .. etc continuously

 

I hope my question is pretty clear =T

also the arrays will be HUGE in size (approx 1500 elements; so its a 1 x 1500 array)

 

can anyone help? please let me know! thanks in advance! 

0 Kudos
Message 1 of 11
(4,422 Views)
hope this helps:
Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
Message 2 of 11
(4,416 Views)

wow thanks for your fast reply

your VI program works nicely but it's not EXACTLY what i am looking for

 

i see that it concatenates the data giving me an array with many rows

but i actually need it to give me only 1 row for every result

 

so there will be a continuum of a 1 row array coming every 2 seconds

 

so lets start with [0  0  0]

first data after 2 seconds is [1  1  1]

so then it becomes [1  1  1]

 

then after another second, another data with array comes [2  2  2]

then i want it to only have [3  3  3]

 

sorry if i wasn't clear about my problem 😞

thanks again in advance! 

  

0 Kudos
Message 3 of 11
(4,410 Views)
Solution
Accepted by topic author spark3

What is confusing is that your subject mentions a 2-D array, but your description describes a 1-D array.

 

Here is a modification to Harold's example that does what you describe.

 

Message Edited by Ravens Fan on 09-20-2009 09:06 PM
Message 4 of 11
(4,406 Views)

wow im sorry,

you are completely right. i actually needed a summation of a 1-D array

thanks for the fix!

 

i tried your set up but it doesnt seem to actually add the arrays.

it seems like the previous array is not being added to the next one.

Message Edited by spark3 on 09-20-2009 09:24 PM
0 Kudos
Message 5 of 11
(4,390 Views)
I'm sorry, it's because I made the initial array to the shift register an empty array.  So something added to an empty array results in an empty array.  Expand the array constant going into the shift register and add a zero for however many elements are in your 1-D array.
0 Kudos
Message 6 of 11
(4,377 Views)

yea i tried that before you posted your message but the problem is that it isnt really adding.

its just adding to a 1D array with all zeros

 

so like i put in [ 2  2  2 ]

comes out [ 2  2  2] (good for the first step)

 

then i put in [1  1  1 ]

comes out [ 1  1  1 ] when i want it to become [ 3  3  3 ]

 

seems like its getting zero'd out every run =T

i guess i will fool around with it and let you know when i get a result!

thanks a bunch! you guys are awesome

0 Kudos
Message 7 of 11
(4,365 Views)
did you try this?
Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
0 Kudos
Message 8 of 11
(4,361 Views)

that just adds 1 to all elements

perhaps my explaining was really bad

 

here is an example what i need

 

first array [1  2  3]

result = [ 1  2  3 ]

 

then second array comes in [4  5  6]

i need result from (1) + second array to give me [ 5  7  9]

 

then third array comes in [ 7  8  9]

i need result from (2) + third array to give me [ 12  15  18 ]

 

and etc. these numbers are just random numbers.. in reality it will be an array of number that has 1500 elements

0 Kudos
Message 9 of 11
(4,352 Views)

spark3 wrote:

yea i tried that before you posted your message but the problem is that it isnt really adding.

its just adding to a 1D array with all zeros

 

so like i put in [ 2  2  2 ]

comes out [ 2  2  2] (good for the first step)

 

then i put in [1  1  1 ]

comes out [ 1  1  1 ] when i want it to become [ 3  3  3 ]

 

seems like its getting zero'd out every run =T

i guess i will fool around with it and let you know when i get a result!

thanks a bunch! you guys are awesome


 

Then post whatever VI you have right now.  You must not have wired something correctly because my example shows how the new array is added to the result of the previous loop iteration, just like you say you want.  My guess is that you have normal tunnels wired rather than shift registers.

 

The only other problem is that since this is a while loop with a rather short wait time, the additions quickly run away before you have a chance to change the input array and have it intentionally add the input array to the results.

Message Edited by Ravens Fan on 09-21-2009 12:10 AM
0 Kudos
Message 10 of 11
(4,348 Views)