LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sum two consecutive elements in a LARGE array

Hi,
my question is, how can I sum two consecutive elements in a LARGE array and calculate the Min and Max.

My 1D-array has 1800000 rows. I need to add the following elements: 0+1, 2+3, 4+5, 6+7 ... and so on.
So my loop needs only 1800000/2 iterations.
What is the fastest way to do this?
At the moment I have a while loop where 2 elements will be deleted from the array and added together. The resulting array w/ subset deleted is connected to a shift-register.
Is this the fastest way? Due to the fact that with every iteration 2 elements are deleted the operation will accelerates.
Maybe there is another solution to calculate the Min and Max.??

I have attached an picture of the while-loop.

I would be thankful
for every tip.

Regards Tomm
0 Kudos
Message 1 of 7
(3,886 Views)
Hi Tomm

An easy aproach could be:
Use "Decimate 1D array" with 2 outputs and add these outputs. It is simple and fast. Then use the "array max & min" to find Max/Min.

Hope it helps.
Alipio
---------------------------------------------------------
"Qod natura non dat, Salmantica non praestat"
---------------------------------------------------------
0 Kudos
Message 2 of 7
(3,886 Views)
That's just what I was going to say! 🙂

Good luck, Tom!

Eric
Eric P. Nichols
P.O. Box 56235
North Pole, AK 99705
0 Kudos
Message 3 of 7
(3,886 Views)
Hi,

thanks for your answers. However in the meantime I've found a better way.
The best way is to open the file with the data and read the data piecemeal.
Then sum the appropriate values and read new data from file. That method is very fast. 🙂

Tomm
0 Kudos
Message 4 of 7
(3,886 Views)
Hi there!

I've been trying to do the same...would you please send me an example to show me how you did that?

Thanks in advance

Tiano
0 Kudos
Message 5 of 7
(3,886 Views)
Hi Tiano,

I've attached a file where you can see how I solved the problem.
Let me know if it helps. Otherwise we can look for another solution.

Regards Tomm
0 Kudos
Message 6 of 7
(3,886 Views)
The Vi I wanted to do was a bit different. I wanted to subtract the second element by the first, the third by the second and so on. Looking to your exampl, I got the light...I manage to do what I wanted. Thanks again...

Tiano
0 Kudos
Message 7 of 7
(3,886 Views)