c语言写的fir低通滤波器.doc

上传人:豆**** 文档编号:23885122 上传时间:2022-07-02 格式:DOC 页数:32 大小:417.50KB
返回 下载 相关 举报
c语言写的fir低通滤波器.doc_第1页
第1页 / 共32页
c语言写的fir低通滤波器.doc_第2页
第2页 / 共32页
点击查看更多>>
资源描述

《c语言写的fir低通滤波器.doc》由会员分享,可在线阅读,更多相关《c语言写的fir低通滤波器.doc(32页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、Four short words sum up what has lifted most successful individuals above the crowd: a little bit more.-author-datec语言写的fir低通滤波器c语言写的fir低通滤波器根据fir滤波器的公式y(n)=h(m)x(n-m);(m: 0(N-1).利用MATLAB产生滤波器系数(h(n)并归一化,下面为一个LP滤波算法void filter(void)uint16 i,j;fp32 sum;int16 x12030;fp32 h19= -0.0027, -0.0025, 0.0050,

2、 0.0157, -0.0000, -0.0471, -0.0482, 0.0838, 0.2953, 0.4013,0.2953, 0.0838, -0.0482, -0.0471, -0.0000,0.0157, 0.0050, -0.0025, -0.0027;for(i=0;i2020;i+)x1i = data0i;for(i=0;i2020;i+)sum=0.0;for(j=0;j= j)sum+=hj*x1i-j;else;data0i=(int16)sum;for(i=0;i2000;i+)data0i = data0i+20;考虑到前19个点为不完全累加和,故抛去前19个点。

3、(应该是前后各18个点都是不完全累加和,都应该去掉,对于数据分段进入滤波器的情况,应该把前一段的后面数据放到下一段的前面,这段时间我在解调FSK时遇到了这个问题,通过滤波器的数据的分段处理。)设输入数据xN,输出数据yN,滤波器系数hn1.直接法(由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 15; 乘法器使用次数:N*n2.逆推法:void

4、fir(short x, short h, short y) int i,j; long sum; for (j = 0; j n; j+) for (i = 0; i 15; 乘法器使用次数:N*n3.倒序法:(输入输出可以是同一量)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 += xj-i * hi; yj = sum 15; #include #include #define true 1#define

5、false 0#define n 8#define bufsize 100 /* the buffer size is 100 */* global declarations */int in_bufferbufsize; /* processing data buffers */int out_bufferbufsize;/* functions */static int processing(int *input, int *output);static void dataio(void);static long round(long a);void main() int *input =

6、 &in_buffer0; int *output = &out_buffer0; puts(the 1st experiment startedn); /* loop forever */ while(true) /* * read input data using a probe-point connected to a host file. * write output data to a graph connected through a probe-point. */ / read the input signal. / if the input file is sine1.dat,

7、 the signal contains 300hz,400hz and 500hz. / if the input file is sine2.dat, the signal contains 100hz,400hz and 500hz. / the sampling frequency is 1200hz. dataio(); /* remove the frequency compoment of 400hz and 500hz*/ processing(input, output); / write the output signal. / the output file is res

8、ult.dat. dataio(); /* * = processing = * * function: apply a low-pass fir filter to input signal and remove the frequency higher than 350hz. * * parameters: address of input and output buffers. * * return value: true. */static int processing(int *input, int *output) int i,size = bufsize; short xx0,x

9、,y; / short zn=0,0,0,0,0,0,0,0,0; short zn=0,0,0,0,0,0,0,0;/short w2*n+1=22,356,155,990,466,220,777,216,777,26,466,9,155,0,22;/short w2*n+1=6,457,56,1024,224,418,523,382,784,99,784,43,523;/ short w2*n+1=330*2,3299*2,1982*2,6867*2,4955*2,1594*2,6607*2,1065*2,4955*2,109*2,1982*2,17*2,330*2; /short w2*

10、n+1=661,6598,3964,13733,9910,3187,13214,2131,9910,217,3964,34,661; / short w2*n+1=58,5628,526,8192,2105,5883,4913,3829,7369,1543,7369,504,4913,102,2105,14,526,1,58; /short w2*n+1=28,4432,280,8192,1259,4883,3356,3975,5873,1509,7048,644,5873,142,3356,30,1259,3,280,0,28; / short w2*n+1=26,651,182,1024,

11、545,421,909,247,909,51,545,11,182,1,26;/short w2*n+1=831,20846,5815,32768,17445,13486,29075,7888,29075,1647,17445,349,5815,21,831;/short w2*n+1=208,5211,1454,8192,4361,3371,7269,1972,7269,412,4361,87,1454,5,208; short w2*n+1=101,4356,810,8192,2835,3403,5670,2517,7088,605,5670,193,2835,21,810;/ short

12、 w2*n+1=101,4356,810,8192,2835,3403,5670,2517,7088,605,5670,193,2835,21,810,2,101; / short w2*n+1=50,3814,454,8192,1815,3504,4235*,3084,6353,831,6353,349,4235,50,1815,8,454,0,50; long y0,z0;/22222222222222 while(size-) xx0=*input+; x=xx0*6; z0=(long)x15; y0=0; for(i=0;i15); y0=round(y0); for(i=n-1;i

13、0;i-) zi=zi-1; z0=round(z0); z0=(short)(z015); y=(short)(y015); *output+ =y; /* additional processing load */ return(true);/* * = dataio = * * function: read input signal and write processed output signal. * * parameters: none. * * return value: none. */static void dataio() /* do data i/o */ return;static long round(long a) long x3; x3=a&(0xffff0000); return x3;-

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 小学资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com