最佳答案
During reading article about filtering, I've found some strange using of .h
file - use it for filling array of coefficients:
#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);
}
So, is it normal practice to use float h[N] = { #include "f1.h" };
this way?