我是靠谱客的博主 不安砖头,最近开发中收集的这篇文章主要介绍数字滤波器设计(高通低通),觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

C语言实现IIR滤波器

//	低通滤波系数(FIR)
//	截止频率12Hz
static double[] h_low = 
{-0.0833280833705624,0.0169383374811856,0.0996331738000324,0.161291094189399,0.199341376750681,0.212202692091625, 0.199341376750681,  0.161291094189399, 0.0996331738000324,
0.0169383374811856, -0.0833280833705624};
//	高通滤波系数(IIR)
// 	截止频率0.5Hz
static double[] h_high_a = 
{ -2.97556554241633,2.95142869449895, -0.975861350573406 };
static double[] h_high_b =
 {0.987856948436085,-2.96357084530825,2.96357084530825,-0.987856948436082 };
private double[] LowBuffer= new double[h_high_b.Length];
private double[] B_buffer = new double[h_high_b.Length];
private double[] A_buffer = new double[h_high_a.Length];
public double Low_Filter(double x)
{
	int i;
	for(i=0;i<h_low.Length-1;i++)
	{
		LowBuffer[i] = LowBuffer[i + 1];
	}
	LowBuffer[h_low.Length - 1] = x;
	double result=0;
	for (i = 0; i < h_low.Length; i++)
		result += LowBuffer[i] * h_low[i];
	return result;
}
public double High_Filter(double x)
{
     B_buffer[0] = x;
     double result = 0.0;
	 int i = 0;
	 for (i = 0; i < B_buffer.Length; i++)
        result += B_buffer[i] * h_high_b[i];
     for (i = 0; i < A_buffer.Length; i++)
        result -= A_buffer[i] * h_high_a[i];
     for (i = B_buffer.Length-1; i > 0 ; i--)
        B_buffer[i] = B_buffer[i - 1];
     for (i = A_buffer.Length - 1; i > 0; i--)
        A_buffer[i] = A_buffer[i - 1];
     if (result > 1.0e10)
        result=4096;
     if(result<-1.0e10)
        result = -4096;
     A_buffer[0] = result;
        return result;
 }

最后

以上就是不安砖头为你收集整理的数字滤波器设计(高通低通)的全部内容,希望文章能够帮你解决数字滤波器设计(高通低通)所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(52)

评论列表共有 0 条评论

立即
投稿
返回
顶部