1.877.352.9158  (Price in US$)

Welcome Guest!   

My Account  |  Cart Contents  |  Checkout

Quick Links To Products
Average value of previous 5 samples
Equation Description:
The equation can be applied to any channel for the averaged values of the previous five readings.
Equation Contents:
bool FirstTime = true;
int AverageOn = 5;
double[] PreviousValues = new double[5];
//A custom equation calculate the averaged values of the previous five readings
public double Ave5Points(double Input)
{
//this is the first time
if(FirstTime)
{
FirstTime = false;
for(int i = 0; i < PreviousValues.Length; i++)
{
PreviousValues[i] = Input;
}
return Input;
}
else
{
double average = 0;
for(int i = 0; i < PreviousValues.Length - 1; i++)
{
average += PreviousValues[i];
PreviousValues[i] = PreviousValues[i + 1];
}
PreviousValues[PreviousValues.Length -1] = Input;
//average
average += Input;
average /= PreviousValues.Length;
return average;
}
}