使用FIR 滤波器算法实现带阻滤波器的示例代码
时间: 2023-02-06 08:25:43 浏览: 68
使用 FIR 滤波器算法实现带阻滤波器的示例代码如下:
```
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323846
// 这里使用数组来表示滤波器的系数
double firCoeffs[] = {
0.0013, 0.0039, 0.0078, 0.0116, 0.0149, 0.0173, 0.0184, 0.0178, 0.0153, 0.0108,
0.0045, -0.0027, -0.0109, -0.0194, -0.0275, -0.0345, -0.0396, -0.0420, -0.0412, -0.0367,
-0.0281, -0.0154, 0.0007, 0.0189, 0.0379, 0.0561, 0.0717, 0.0836, 0.0909, 0.0929,
0.0891, 0.0793, 0.0638, 0.0435, 0.0198, -0.0057, -0.0325, -0.0584, -0.0822, -0.1022,
-0.1167, -0.1247, -0.1256, -0.1196, -0.1067, -0.0875, -0.0627, -0.0337, -0.0023, 0.0298,
0.0618, 0.0916, 0.1178, 0.1392, 0.1547, 0.1635, 0.1651, 0.1592, 0.1462, 0.1265,
0.1011, 0.0711, 0.0377, 0.0027, -0.0330, -0.0686, -0.1031, -0.1357, -0.1654, -0.1912,
-0.2125, -0.2284, -0.2384, -0.2421, -0.2391, -0.2295, -0.2136, -0.1917, -0.1644, -0.1323,
-0.0962, -0.0570, -0.0162, 0.0257, 0.0672, 0.1078, 0.1462, 0.1814, 0.2124, 0.2382,
0.2578, 0.2708, 0.2767, 0.2753, 0.2667, 0.2509, 0.2281, 0.1987, 0.1630, 0.1214,
0.0749, 0.0246, -0.0277, -0.0804, -0.1325, -0.1827, -0.2298, -0.2723, -0.3094, -0.3398