02-08-2012 11:10 AM
Hello,
I found the vi to make the average of the last five values here : https://decibel.ni.com/content/docs/DOC-4013
But i think that it is not really the average of the last five values...
The problem in my opinion is that the shift register on the left should contain only 4 and not 5 elements.
Can someone check it ?
Thanks to answer
02-08-2012 11:19 AM
Hi you are correct, looking at that example it does not take the average of the last 5 values. It should have only four shift registers and the top one should be wired up. Then it would average the current data point with the previous four data points. I will update the example to make sure it is correct.
Thank you for pointing this out.
Regards
02-08-2012 11:44 AM
As a note, I rewrote that example as a snippet and added the code saved for LabVIEW 2011, 2010 and 8.6.
Regards,
02-08-2012 12:15 PM
,
if the purpose is to use as a slide mean the first version is good
event if shift register is 4 elements size when averaging with the current one
this is the mean of last five values mesured for exemple.
am i alone ?
Regards
Tinnitus
02-08-2012 12:42 PM
The code at the link has been updated with my revised version. The original code looked like this -
Because it uses five shift registers and the top register is not wired up, it is not averaging the current value with the previous four values. It averages the nth value with the n-2,n-3,n-4,and n-5 values but it skips the n-1 value. Am I wrong?
Regards,
02-08-2012 12:53 PM - edited 02-08-2012 12:54 PM
That looks like the correct fix to me. The previous version was definitely wrong.
I wanted to add a comment to that article in the community zone, but couldn't find a way to do it event though I was logged in.
There is a comment that the results are in valid for the first 4 iterations. The way to fix that is to divide by the number of iteration that have occurred using the In range and coerce function to limit it to 5.

02-08-2012 12:54 PM
ok
02-08-2012 02:44 PM
Isn't this the same thing?
02-08-2012 03:03 PM
@aeastet wrote:
Isn't this the same thing?
It is if you have the full development system.
02-08-2012 03:05 PM
I tried to attach that modified version to the example but it was temporarily not letting me attach images, so I put in a link to this thread. The Coerce is a nice fix.