1. Use matlab to generate parameters.
static float test_f(float input)
{
static float xv[2+1], yv[2+1];
xv[0] = xv[1]; xv[1] = xv[2];
xv[2] = input/ 1.949595788e+02;
yv[0] = yv[1]; yv[1] = yv[2];
yv[2] = (xv[0] + xv[2]) + 2 * xv[1]
+ ( -0.8079495914 * yv[0]) + ( 1.7874325180 * yv[1]);
return yv[2];
}
static float iir_filter_matab(float input)
{
//y[n] = 1*x[n] + 2*x[n-1] + 1*x[n-2] - (-1.1429805025)*y[n-1] - (0.412801596)*y[n-2]
// matlab 都是二阶滤波级联
double gain = 0.005129268366107;
float table_N[3] = {1,2,1};
float table_D[3] = { 1, -1.787432517956, 0.8079495914209};
static float xv[3], yv[3];
xv[2] = input*gain;
xv[0] = xv[1]; xv[1] = xv[2];
yv[0] = yv[1]; yv[1] = yv[2];
yv[2] = table_N[0]*xv[2]+table_N[1]*xv[1]+table_N[2]*xv[0] - table_D[1]*yv[1] - table_D[2]*yv[0];
return yv[2];
}
y [n] = b0⋅x [n] + b1⋅x [n − 1] + b2⋅x [n − 2] −a1⋅y [n − 1] −a2⋅y [n − 2]
High-order filtering in matlab is cascaded with second-order filtering.
The filtering effect of the code generated by the test and the web version is basically the same.
Web version generates C language
https://www-users.cs.york.ac.uk/~fisher/mkfilter/trad.html
Summarize the variance as the data dispersion.