如题,我用MATLAB生成的h[]参数,在CCS里用C语言写的FIR滤波器,做实验得到的数据完全没有经过滤波,相反我用网站生成的一个IIR滤波器可以起到作用,FIR不是只要做简单的卷积就行了,为什么没有一点效果呢,程序如下:
int h[34]={48,35,-48,-112,0,235,203,-278,-603,0,1052,857,-1144,-2550,0,6477,12212,12212,6477,0,-2550,-1144,857,1052,0,-603,-278,203,235,0,-112,-48,35,48};
int m,n,sum;
for(m=0;m<1024;m++)
{
sum=0;
for(n=0;n<34;n++)
{
if(m>=n)
sum+=h[n]*FBUF[m-n]/32768;
else;
}
Dbuf[m]=sum;
}
/
哪位可以告诉我为什么吗??下面的是有效的巴特沃斯滤波器的程序
int i;
for (i=0;i<1024;i++)
{ xv[0] = xv[1]; xv[1] = xv[2]; xv[2] = xv[3]; xv[3] = xv[4]; xv[4] = xv[5]; xv[5] = xv[6]; xv[6] = xv[7]; xv[7] = xv[8]; xv[8] = xv[9]; xv[9] = xv[10];
xv[10] = FBUF[i]/ GAIN;
yv[0] = yv[1]; yv[1] = yv[2]; yv[2] = yv[3]; yv[3] = yv[4]; yv[4] = yv[5]; yv[5] = yv[6]; yv[6] = yv[7]; yv[7] = yv[8]; yv[8] = yv[9]; yv[9] = yv[10];
yv[10] = (xv[0] + xv[10]) + 10 * (xv[1] + xv[9]) + 45 * (xv[2] + xv[8])
+ 120 * (xv[3] + xv[7]) + 210 * (xv[4] + xv[6]) + 252 * xv[5]
+ ( -0.0001487645 * yv[0]) + ( 0.0026689124 * yv[1])
+ ( -0.0224985093 * yv[2]) + ( 0.1157186252 * yv[3])
+ ( -0.4144462688 * yv[4]) + ( 1.0545446211 * yv[5])
+ ( -2.0387206371 * yv[6]) + ( 2.8185224265 * yv[7])
+ ( -3.0194828634 * yv[8]) + ( 1.9924014816 * yv[9]);
Dbuf[i] = yv[10];
} |