#include <algorithm>
#include <mutex>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <malloc.h>
#include <string.h>
class IIR{
private:
const int NL = 5;
const double b[5] = {0.3, -3., 6, -3., 1};
const int DL = 5;
const double a[5] = { 1, -3., 6, -3, 1};
std::vector<double> coefs;
public:
IIR() {
coefs.resize(DL);
};
double filter(double value)
{
double current_Y = b[0] * value + coefs[0];
for (int i = 1; i < DL; i++)
{
coefs[i - 1] = b[i] * value + coefs[i] - a[i] * current_Y;
}
return current_Y;
}
};
IIR 滤波器的C++实现 亲测ok
于 2023-11-30 11:10:59 首次发布