数字滤波样例.doc

上传人:laozhun 文档编号:4143212 上传时间:2023-04-07 格式:DOC 页数:7 大小:52.50KB
返回 下载 相关 举报
数字滤波样例.doc_第1页
第1页 / 共7页
数字滤波样例.doc_第2页
第2页 / 共7页
数字滤波样例.doc_第3页
第3页 / 共7页
数字滤波样例.doc_第4页
第4页 / 共7页
数字滤波样例.doc_第5页
第5页 / 共7页
点击查看更多>>
资源描述

《数字滤波样例.doc》由会员分享,可在线阅读,更多相关《数字滤波样例.doc(7页珍藏版)》请在三一办公上搜索。

1、6均值滤波可以有效地去除叠加在低频信号上的噪声。现有一个被噪声污染的信号x(n)= s(n)+d(n),式中为原始信号,d(n)为均匀分布的噪声。现将x(n)输入到M点的滑动平均滤波器去滤除噪声,提取原始信号 s(n)。已知滑动平均滤波器的数学模型为:试分析M取不同值时对输出信号的影响如何?原因是什么?滑动平均滤波法:1 方法:把连续N个采样值看成一个队列,队列的长度固定为N。每次采样到一个新数据放入队尾,并扔掉原来队首的一次数据(先进先出原则),把队列中的N个数据进行算术平均运算,就可获得新的滤波结果。2 优点:对周期性干扰有良好的抑制作用平滑度高,适用于高频振荡的系统。3 缺点:灵敏度低,

2、对偶然出现的脉冲性干扰的抑制作用较差,不易消除由于脉冲干扰所引起的采样值偏差,不适用于脉冲干扰比较严重的场合。比较浪费内存。以下程序中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(原信号加噪声信号波形);xla

3、bel(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

4、(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 He

5、lp 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-

6、. 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

7、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

8、), 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 -

9、 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 gen

10、erators. 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 statistic

11、al 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 s

12、tate. 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 unifo

13、rm 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 algo

14、rithm, 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 i

15、n 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 dimensi

16、ons 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 ar

17、ray 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)

18、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

19、/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 he

20、lp 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 help xregusermod/size.m help xregunispline/size.m help xregtwostage/size.m help xregmultilin/size.m help xregmulti/size.m help xregmodswitc

21、h/size.m help xregmodel/size.m help xreglinear/size.m help localusermod/size.m help localtruncps/size.m help localsurface/size.m help localpspline/size.m help localmulti/size.m help localbspline/size.m help xregmonitorplotproperties/size.m help xregdataset/size.m help sweepsetfilter/size.m help sweepset/size.m help guidarray/size.m help mpc/size.m help opcroot/size.m help uss/size.m help umat/size.m help ufrd/size.m help ndlft/size.m help icsignal/size.m help atom/size.m Reference page in Help browser doc size

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 办公文档 > 其他范文


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号