07-01-2024 01:36 PM
I know the subject is a word soup but I'll try and clarify here.
In 60 second increments, for an experiment total time of 1 hour, I am trying to add a 1 or 0 to an array(comes from experiment input and not relevant) each second.
I want to compare the sum of 1's to a user determined fail threshold(this part is covered, its just for clarity of what I'm trying to accomplish).
After the first 60 seconds, I want to compare the sum to the last 60 seconds...for example at t = 63s, I want call the sum of values from elements 2-62 to compare with the fail condition threshold. So basically, how do I create a sum that moves with time equal to the previous 60 seconds.
I have tried to next a for loop inside of a while loop, but it seems to refill the array with new values instead of appending it, and I cannot for the life of me find a way to call a range of elements in an array. Would greatly appreciate any ideas on how to achieve this!
Solved! Go to Solution.
07-01-2024 01:52 PM
Hi Jacob,
@wwjacobd wrote:
After the first 60 seconds, I want to compare the sum to the last 60 seconds...for example at t = 63s, I want call the sum of values from elements 2-62 to compare with the fail condition threshold. So basically, how do I create a sum that moves with time equal to the previous 60 seconds.
This is called "running sum": you can easily create this using a Pt-By-Pt-DataQueue function, set to hold 60 samples…
07-01-2024 02:56 PM
This exactly what I was trying to accomplish. Thank you!
07-01-2024 03:08 PM
This can be achieved manually with a circular buffer, something like so.