重写 function low-pass filter
Applies a low-pass filter to sequences of valid temperature readings for consecutive times.* If a non-valid temperature reading is found, the filter should restart at the next valid
* temperature reading. The following describes the low-pass filter used:
*
* filtered_output(0) = unfiltered_input(0)
* filtered_output(n) = 0.9375 * filtered_output(n-1) + 0.0625 * unfiltered_input(n)
*
*/
void LowPassFilter(ACTempData acTemps[])
{
int a; // The first valid data.
int i;
int n;
a = 0;
i = 0;
n = 1;
while(acTemps[a].valid != 1)
++a;
for(i = a; i < MinPerDay; ++i){
n = 1;
while(i != a && acTemps[i-n].valid == 0)
++n;
if(i != a && acTemps[i].valid == 1){
acTemps[i].temperature = 0.9375 * acTemps[i-n].temperature + 0.0625 * acTemps[i].temperature;
}
}
}
我实在没有办法了,只能求助论坛了。如何用另一种形势,比如改while 等等来重写这个function
[ 本帖最后由 yuchao130 于 2014-9-12 03:03 编辑 ]