09-20-2009 06:31 PM
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!
Solved! Go to Solution.
09-20-2009 07:12 PM
09-20-2009 07:35 PM
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!
09-20-2009 08:06 PM - edited 09-20-2009 08:06 PM
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.
09-20-2009 09:17 PM - edited 09-20-2009 09:24 PM
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.
09-20-2009 09:41 PM
09-20-2009 10:34 PM
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
09-20-2009 10:46 PM
09-20-2009 11:02 PM
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
09-20-2009 11:08 PM - edited 09-20-2009 11:10 PM
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.