zoukankan      html  css  js  c++  java
  • 直接型FIR滤波器的C语言实现

     

     

    <span style="color:red"> This blog is out of date. Check out my new blog holder: <a href='https://sonictl.github.io'>sonictl.github.io</a></span>

     

    <span style="color:red"> 本网站上的博文已经停止维护/更新了。 请移步到新的博客空间:<a href='https://sonictl.github.io'>sonictl.github.io</a></span>

     

     

    直接型FIR滤波器的C语言实现

      

    设输入数据x[N],输出数据y[N],滤波器系数h[n]

    1.直接法(由y(m)=h(0)*x(m)+h(1)*x(m-1)+...+h(N-1)*x(m-n-1));

    void fir(short x[], short h[], short y[])
    {
      int i,j;
      long long sum;  
     
      for (j = 0; j < N; j++)
      {
        sum = 0;
        for (i = 0; i < n; i++)
          sum += x[j-i] * h[i];
        y[j] = sum >> 15;
      }
    }

    乘法器使用次数:N*n

     

    2.逆推法:

    void fir(short x[], short h[], short y[])
    {
      int i,j;
      long sum;  
     
      for (j = 0; j < n; j++)
      {
        for (i = 0; i < N; i++)
        {
          sum = 0;
          sum = h[j] * x[i]
          y[i] += sum >> 15;
        }
      }
    }

    乘法器使用次数:N*n

     

    3.倒序法:(输入输出可以是同一量)

    void fir(short x[], short h[], short y[])
    {
      int i,j;
      long long sum;  
     
      for (j = N; j > 0; j--)
      {
        sum = 0;
        for (i = n; i > 0; i--)
          sum += x[j-i] * h[i];
        y[j] = sum >> 15;
      }
    }




  • 相关阅读:
    迭代器基础知识
    C语言I博客作业09
    第一周作业
    C语言1博客作业04
    C语言I博客作业08
    C语言博客作业05
    C语言I作业12—学期总结
    C语言I博客作业10
    C语言I博客作业06
    C语言I博客作业11
  • 原文地址:https://www.cnblogs.com/sonictl/p/6735641.html
Copyright © 2011-2022 走看看