数字滤波样例.doc_第1页
数字滤波样例.doc_第2页
数字滤波样例.doc_第3页
数字滤波样例.doc_第4页
数字滤波样例.doc_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

6均值滤波可以有效地去除叠加在低频信号上的噪声。现有一个被噪声污染的信号x(n)= s(n)+d(n),式中为原始信号,d(n)为均匀分布的噪声。现将x(n)输入到m点的滑动平均滤波器去滤除噪声,提取原始信号 s(n)。已知滑动平均滤波器的数学模型为:试分析m取不同值时对输出信号的影响如何?原因是什么?滑动平均滤波法:1 方法:把连续n个采样值看成一个队列,队列的长度固定为n。每次采样到一个新数据放入队尾,并扔掉原来队首的一次数据(先进先出原则),把队列中的n个数据进行算术平均运算,就可获得新的滤波结果。2 优点:对周期性干扰有良好的抑制作用平滑度高,适用于高频振荡的系统。3 缺点:灵敏度低,对偶然出现的脉冲性干扰的抑制作用较差,不易消除由于脉冲干扰所引起的采样值偏差,不适用于脉冲干扰比较严重的场合。比较浪费内存。以下程序中m值的选取:m1=3,m2=10matlab程序如下:n=1:100;sn=2*n.*(0.9).n;figure(1);subplot(3,1,1);plot(n,sn);title(原信号波形);xlabel(n);dn=rand(size(sn);subplot(3,1,2);plot(n,dn);title(噪声信号波形);xlabel(n);xn=sn+dn;subplot(3,1,3);plot(n,xn);title(原信号加噪声信号波形);xlabel(n);m=3;for k=1:m-1 xn1(k)=0; xn2(k)=0;endfor k=m:100 xn1(k)=xn(k-1); xn2(k)=xn(k-2);endyn1=1/m.*(xn+xn1+xn2);figure(2);subplot(2,1,1);plot(n,yn1);title(m取3时的滤波波形);xlabel(n);m=10;for k=1:m-1; xn1(k)=0;xn2(k)=0;xn3(k)=0;xn4(k)=0;xn5(k)=0;xn6(k)=0;xn7(k)=0;xn8(k)=0;xn9(k)=0;endfor k=m:100 xn1(k)=xn(k-1);xn2(k)=xn(k-2);xn3(k)=xn(k-3);xn4(k)=xn(k-4);xn5(k)=xn(k-5); xn6(k)=xn(k-6);xn7(k)=xn(k-7);xn8(k)=xn(k-8);xn9(k)=xn(k-9);endyn2=1/m.*(xn+xn1+xn2+xn3+xn4+xn5+xn6+xn7+xn8+xn9);subplot(2,1,2);plot(n,yn2);title(m取10时的滤波波形);xlabel(n) 程序运行结果如下: to get started, select matlab help or demos from the help menu. help rand rand uniformly distributed pseudo-random numbers. r = rand(n) returns an n-by-n matrix containing pseudo-random values drawn from a uniform distribution on the unit interval. rand(m,n) or rand(m,n) returns an m-by-n matrix. rand(m,n,p,.) or rand(m,n,p,.) returns an m-by-n-by-p-by-. array. rand with no arguments returns a scalar. rand(size(a) returns an array the same size as a. you can use any one of three generator algorithms, as follows: rand(method,s) causes rand to use the generator determined by method, and initializes the state of that generator. s is a scalar integer value from 0 to 232-1, or the output of rand(method). method is one of the following strings: state - use a modified version of marsaglias subtract-with-borrow algorithm, the default in matlab versions 5 and later. this method can generate all the double precision values in the closed interval 2(-53), 1-2(-53), and, theoretically, can generate over 21492 values before repeating itself. seed - use a multiplicative congruential algorithm, the default in matlab version 4. this method generates double precision values in the closed interval 1/(231-1), 1-1/(231-1), with a period of 231-2. twister - use the mersenne twister algorithm by nishimura and matsumoto. this method generates double precision values in the closed interval 2(-53), 1-2(-53), with a period of (219937-1)/2. rand(method) returns the current internal state of the generator determined by method. however, it does not switch generators. the sequence of numbers produced by rand is determined by the internal state of the generator. setting the generator to the same fixed state allows computations to be repeated. setting the generator to different states leads to unique computations, however, it does not improve any statistical properties. since matlab resets the state at start-up, rand will generate the same sequence of numbers in each session unless the state is changed. note: the size inputs m, n, and p. should be nonnegative integers. negative integers are treated as 0. examples: return rand to its default initial state. rand(state,0) initialize rand to a different state each time. rand(state,sum(100*clock) save the current state, generate 100 values, reset the state, and repeat the sequence. s = rand(state); u1 = rand(100); rand(state,s); u2 = rand(100); % contains exactly the same values as u1 generate uniform values from the interval a, b. r = a + (b-a).*rand(100,1); generate integers uniform on the set 1:n. r = ceil(n.*rand(100,1); use the mersenne twister generator, with the default initial state used by nishimura and matsumoto. rand(twister,5489); for a full description of the mersenne twister algorithm, see http:/www.math.sci.hiroshima-u.ac.jp/m-mat/mt/emt.html. see also randn, sprand, sprandn, randperm. reference page in help browser doc rand help size size size of array. d = size(x), for m-by-n matrix x, returns the two-element row vector d = m,n containing the number of rows and columns in the matrix. for n-d arrays, size(x) returns a 1-by-n vector of dimension lengths. trailing singleton dimensions are ignored. m,n = size(x) for matrix x, returns the number of rows and columns in x as separate output variables. m1,m2,m3,.,mn = size(x) for n1 returns the sizes of the first n dimensions of the array x. if the number of output arguments n does not equal ndims(x), then for: n ndims(x), size returns ones in the extra variables, i.e., outputs ndims(x)+1 through n. n ndims(x), m will be 1. when size is applied to a java array, the number of rows returned is the length of the java array and the number of columns is always 1. when size is applied to a java array of arrays, the result describes only the top level array in the array of arrays. example: if x = rand(2,3,4); then d = size(x) returns d = 2 3 4 m1,m2,m3,m4 = size(x) returns m1 = 2, m2 = 3, m3 = 4, m4 = 1 m,n = size(x) returns m = 2, n = 12 m2 = size(x,2) returns m2 = 3 see also length, ndims, numel. overloaded functions or methods (ones with the same name in other directories) help timer/size.m help serial/size.m help tscollection/size.m help timeseries/size.m help gf/size.m help zpk/size.m help tf/size.m help ss/size.m help frd/size.m help daqdevice/size.m help daqchild/size.m help fints/size.m help idmodel/size.m help idfrd/size.m help iddata/size.m help videosource/size.m help videoinput/size.m help visa/size.m help udp/size.m help tcpip/size.m help icgroup/size.m help icdevice/size.m help gpib/size.m help xregpointer/size.m help cgoppoint/size.m help xregdesign/size.m help designdev/size.m help candidateset/size.m help xregtable/size.m help xreglistctrl/size.m hel

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论