在阅读有关过滤的文章时,我发现.h
文件有一些奇怪的用法——用它填充系数数组:
#define N 100 // filter order
float h[N] = { #include "f1.h" }; //insert coefficients of filter
float x[N];
float y[N];
short my_FIR(short sample_data)
{
float result = 0;
for ( int i = N - 2 ; i >= 0 ; i-- )
{
x[i + 1] = x[i];
y[i + 1] = y[i];
}
x[0] = (float)sample_data;
for (int k = 0; k < N; k++)
{
result = result + x[k]*h[k];
}
y[0] = result;
return ((short)result);
}
那么,这样使用float h[N] = { #include "f1.h" };
是正常的做法吗?