抗脉冲滤波法
/*
*函数功能:抗脉冲滤波法
输入参数:pArray:待滤波数组
num: 待滤波数据个数
abandonMaxNum:待清除最大数据个数
abandonMinNum:待清除最小数据个数
*返回值:滤波数据结果,如果数据有误,则返回0
/
uint16_t AntiPulse_DigitalFilter(uint16_t pArray,uint16_t num,uint16_t abandonMinNum,uint16_t abandonMaxNum)
{
uint16_t maxvalue;
uint16_t maxtmp;
uint16_t minvalue;
uint16_t mintmp;
uint16_t ui16i;
uint16_t maxcount = 0;
uint16_t mincount = 0;
uint32_t ui32total = 0;
uint32_t ui32max = 0;
uint32_t ui32min = 0;
if((pArray == NULL)||(num <= abandonMaxNum+abandonMinNum)||(num <2)||(num>60))
return 0;
maxvalue = pArray[0];
minvalue = pArray[0];
for(ui16i=0;ui16i<num;ui16i++)
{
maxvalue = _MAX(maxvalue,pArray[ui16i]);
minvalue = _MIN(minvalue,pArray[ui16i]);
ui32total += pArray[ui16i];
}
maxtmp = maxvalue;
mintmp = minvalue ;
while(1)
{
maxvalue =maxtmp;
minvalue = mintmp;
for(ui16i=0;ui16i<num;ui16i++)
{
if(!((abandonMaxNum == maxcount)&&(abandonMinNum == mincount)))
{
if(abandonMaxNum != maxcount)
{
if(pArray[ui16i]== maxvalue)
{
maxcount ++ ;
ui32max += pArray[ui16i];
}
if(ui16i<num-1)
{
maxtmp = _MAXWITHOUT_C(maxtmp,pArray[ui16i],maxvalue);
}
}
if(abandonMinNum != mincount)
{
if(pArray[ui16i]== minvalue)
{
mincount ++ ;
ui32min += pArray[ui16i];
}
if(ui16i<num-1)
{
mintmp = _MINWITHOUT_C(mintmp,pArray[ui16i],minvalue);
}
}
}
else
{
break;
}
}
if(((abandonMaxNum == maxcount)&&(abandonMinNum == mincount)))
break;//while(1)
}
return ((ui32total-ui32max-ui32min)/(num - abandonMaxNum - abandonMinNum));
}
您好,请问您这个函数里面的_MAX和_MIN、 _MAXWITHOUT_C、 _MINWITHOUT_C这几个函数具体是怎样的呢?或者说是要实现什么功能?