Showing results for 
Search instead for 
Did you mean: 

moving average question

@knowlittle wrote:

I posted too hastily. As you advised, I initialized at each loop entry. I am about to connect this program to a real test setup. Thank you all so much.

moving average initilized.PNG

Except you are constantly resetting the average, not just the first iteration.  The i = 0 is the simple way to only initialize on the first iteration of the loop.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 11 of 13

Notice that you have passed TRUE to every iteration of your FOR block, not just the first one. 

0 Kudos
Message 12 of 13

@Gregory wrote:

If you intialize it on the first iteration then you should stop seeing the data from the previous call.




Although if you are seeing this just from using the run arrow then it might be samples buffered from your DAQ instrument?

Thank you for correcting my mistake. I will use this.

In my program, once RUN button is pushed, operator is prompted to replace test samples multiple times and measurement is repeated. The first measurement is okay. But all subsequent measurements show old data affecting new average. Initialization upon Mean PtByPt loop entry will solve the problem.

0 Kudos
Message 13 of 13