LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Delete From Array Error?

Solved!
Go to solution
Solution
Accepted by topic author Mystogan

@Mystogan wrote:

I’m working with code written by someone else, and I found this structure. In principle, the task is quite basic. Our goal is to collect a new measurement value in each iteration, store it in an array, and keep the last 20 values (that’s what I meant by “20” in the first picture). Then I want to calculate the average of those values.

Sorry, but the code I’m working with is quite confusing to me. Also, the value 15 (which in this case should actually be larger than 20, for example 50) is needed so that the array does not keep growing and consuming too much memory.


I am sorry that you need to deal with poor code written by someone else. That's always painful.

 

For a running average (yes, there is also a ptbypt version) the order of elements in the array does not even matter so all you need is a fixed size array in a shift register where you replace the oldest with the newest. Have a look here.

 

For even more efficient versions, have a look at slide 12.. of our presentation here (part II). Code included.

 

 

Message 11 of 12
(89 Views)

@altenbach wrote:

@Mystogan wrote:

I’m working with code written by someone else, and I found this structure. In principle, the task is quite basic. Our goal is to collect a new measurement value in each iteration, store it in an array, and keep the last 20 values (that’s what I meant by “20” in the first picture). Then I want to calculate the average of those values.

Sorry, but the code I’m working with is quite confusing to me. Also, the value 15 (which in this case should actually be larger than 20, for example 50) is needed so that the array does not keep growing and consuming too much memory.


I am sorry that you need to deal with poor code written by someone else. That's always painful.

 

For a running average (yes, there is also a ptbypt version) the order of elements in the array does not even matter so all you need is a fixed size array in a shift register where you replace the oldest with the newest. Have a look here.

 

For even more efficient versions, have a look at slide 12.. of our presentation here (part II). Code included.

 

 


Thank you. Your link is very helpful. I think I found what I needed, and you’re right—I decided not to use Delete From Array, as it was just confusing

0 Kudos
Message 12 of 12
(63 Views)