LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Summing the last n elements of a array

Solved!
Go to solution

I'm collecting data from an instrument once per minute and adding each value to an array. After many days there are alot of values in the array. I want to be able to select a time, ie 4 hours, and have the last 4 hours of values added together so it can be displayed. Any ideas. Thanks in advance for the help.

 

ssmith

0 Kudos
Message 1 of 8
(6,049 Views)
Solution
Accepted by topic author ssmith490D

Use Array Subset and Add Array Elements.

 

Once per minute = 60 values per hour.

Number of Hours * 60 = number of elements you want.

So subtract Number of Elements from Array Size to get your index.

 

Quick and easy!

 

8-)

 


Message Edited by LabViewGuruWannabe on 12-26-2008 03:39 PM
Message Edited by LabViewGuruWannabe on 12-26-2008 03:40 PM
Message 2 of 8
(6,043 Views)

hello,

 

try this

 

 

Arg my pc is too slow  :smileywink:

Message Edité par tinnitus le 12-26-2008 03:40 PM
CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
0 Kudos
Message 3 of 8
(6,035 Views)
 
CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
0 Kudos
Message 4 of 8
(6,029 Views)

I'm guessing this is a continuation of this thread, so my suggestion below is based on this. In the screenshot you posted you are using Build Array. A couple of points first:

 

  • Be aware that this operation will slow down your program over time, as you are continuously increasing the memory footprint by growing your array. 
  • You do not need to use local variables to do that operation. Use a shift register that's attached to your outer while loop.

 

Now, as to your question: Since your samples are not evenly spaced, then you must determine where to take an array subset. To do this you need to know what the time was 4 hours ago, and determine which array element is beyond this. You can accomplish this by a simple comparison operator and then search the 1D array for the first True/False. This tells you where the 4-hour cutoff is, and where you can take the Array Subset.

Message 5 of 8
(6,025 Views)

tinnitus wrote:

try this


From the other thread, it seems that ssmith is using LabVIEW 7.1. Attaching a 8.6 VI without any explanation is not very helpful.

0 Kudos
Message 6 of 8
(6,011 Views)

hello altenbach,

 

there is a simple chain with simulated aquisition that a child could understand,

about 7.1.1 it 's written nowhere, on simple demand i can also repost or send a pict

 

good night ( at least for me)

@+

Tinnitus

 

 

CLAD / Labview 2011, Win Xp
------------------------------------------------------
Mission d'une semaine- à plusieurs mois laissez moi un MP...
RP et Midi-pyrénées .Km+++ si possibilité de télétravail

Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
Don't forget to valid a good answer / pensez à valider une réponse correcte
0 Kudos
Message 7 of 8
(5,997 Views)

Thanks a lot. Works great.

 

ssmith

0 Kudos
Message 8 of 8
(5,979 Views)