我正在通过一个零评论的程序。 这是一个信号滤波器,我想知道这是哪种类型 到目前为止我有这个: 数组(长度=顺序):
过滤步骤:
公式大致: OUT = SUM(i = 0到阶)(X [i] * B [i] - Y [i] * A [i])
移动窗口:所有X和Y移动一个位置,删除最旧的值,并添加新的输入和输出值。
我尝试使用谷歌搜索哪种过滤器,但我有点卡住,特别是之前输出的反馈是我之前没有看到过的(之前我只使用过非常简单的过滤器)。
source:
`float_type floatFilter::addPoint(float_type P)
{
//P is sample value`
if (_pfilterCoefs == NULL) return P;
//
if (_reset)
{
for (uint16_t i=0;i<_pfilterCoefs->order;i++)
{
*(_Ys+i)= _pfilterCoefs->lowpass ? P : 0;
*(_Xs+i)= _pfilterCoefs->lowpass ? P : 0;
}
_reset=false;
}
//calculate output
float_type Y = ((*_pfilterCoefs->Bs)) * P;
for (uint16_t i=0; i<_pfilterCoefs->order; i++)
{
Y+=(*(_Xs+i)) * (*(_pfilterCoefs->Bs + (_pfilterCoefs->order-i))) -
(*(_Ys+i)) * (*(_pfilterCoefs->As + (_pfilterCoefs->order-1-i)));
}
//move filter one step (
for (uint16_t i = 0; i<(_pfilterCoefs->order-1);i++)
{
*(_Ys+i)=*(_Ys+i+1);
*(_Xs+i)=*(_Xs+i+1);
}
*(_Xs + _pfilterCoefs->order - 1) = P; //the most recent input is added in the end
*(_Ys + _pfilterCoefs->order - 1) = Y; //the most recent output is added in the end
return *(_Ys + _pfilterCoefs->order-1); //this is the most recent output.