用双线性变换法设计一个3阶Butterworth数字带通滤波器

2024年11月22日 12:31
有1个网友回答
网友(1):

这是C语言的实现形式,可以直接使用的:

 

 /******************************************************************************/
/* 3rd Order Band Pass Butterworth                                            */
/* 双线性变换 (S域 --> Z域)                                 */
/* 采样频率 = 720.0 Hz                                                */
/* 精度 = 0.0001                                           */
/* 下边带的截止频率= 60.00 Hz                                          */
/* 上边带的截止频率 = 300.0 Hz                                          */
/* 输入参数定义如下:                                                */
/* Inputs:                                                                    */
/*   invar    float       输入滤波器的数据                            */
/*   setic    int         1 to initialize the filter to zero                  */
/*                                                                            */
/* There is no requirement to ever initialize the filter.                    */
/* The default initialization is zero when the filter is first called        */
/******************************************************************************/

double My_BPF(double invar; int setic)
{
    float sumnum, sumden;  int i;
    static float delay[7] = {0.0,0.0,0.0,0.0,0.0,0.0,0.0};
    static float znum[7] = {
        -.3318,
        0.0,
        .9954,
        0.0,
        -.9954,
        0.0,
        .3318
    };
    static float zden[6] = {
        -.106,
        -3.2e-17,
        .5826,
        9.248e-17,
        -.9658,
        -2.423e-16
    };
    if (setic==1){
        for (i=0;i<=6;i++) delay[i] = 1.958*invar;
        return 0.0;
    }
    else{
        sumden=0.0;
        sumnum=0.0;
        for (i=0;i<=5;i++){
            delay[i] = delay[i+1];
            sumden += delay[i]*zden[i];
            sumnum += delay[i]*znum[i];
        }
        delay[6] = invar-sumden;
        sumnum += delay[6]*znum[6];
        return sumnum;
    }
}

 

下面是软件的频域响应: