|
用C语言实现加权递推平均滤波法,程序如下所示:/* coe数组为加权系数表,存在程序存储区。*/#define N 12char code coe[N] = {1,2,3,4,5,6,7,8,9,10,11,12};char code sum_coe = 1+2+3+4+5+6+7+8+9+10+11+12;char filter(){ char count; char value_buf[N]; int sum=0; for (count=0,count<N;count++) { value_buf[count] = get_ad(); delay(); } for (count=0,count<N;count++) sum += value_buf[count]*coe[count]; return (char)(sum/sum_coe);} |
|
共 1 个关于本帖的回复 最后回复于 2013-3-14 09:20