09-24-2012 07:13 AM
I would like to have a file (excel) that has 11,12,13,14,15,16,17,18,19, 20, 21, 22, 23, 24, 25 or any random numbers in no specific order.
I would like to do an rolling calculation everytime the file reads. for example.
Add the first 5 numbers in the file and divide by 5 then drop the first number and move one to the right and get the next 5 number then divide by 5 etc.
(11 + 12 + 13 + 14 + 15) / 5 = 13 the first time it reads then drop off the first number and move one to the right (12 + 13 + 14 + 15 + 16) / 5 = 14 then (13 + 14 + 15 + 16 + 17) / 5 = 15.
Can anyone help please?
Solved! Go to Solution.
09-24-2012 07:49 AM
There are many examples of running / moving averages on this forum. But I do not recall them ever being called rolling averages. So you might want to search for running or moving average.
A recent thread started by me comes to mind.
The simplest example I have seen while loop with shift registers, especially if you do not need to change the sample size at run time.
09-24-2012 07:59 AM
S1ack Thanks for your reply!
09-24-2012 07:59 AM
What have you tried? Can you show you code?
I would use a shift register to hold your 5 element array and use the Mean VI (in the Mathematics->Probability and Statistics palette) to calculate you mean. You can then use the Replace Array Subset to put your new element in the array. I used the Shift 1D Array with a -1 places so that the replaced element was always in the first element.