ch7 随机信号的产生与处理_第1页
ch7 随机信号的产生与处理_第2页
ch7 随机信号的产生与处理_第3页
ch7 随机信号的产生与处理_第4页
ch7 随机信号的产生与处理_第5页
已阅读5页,还剩116页未读 继续免费阅读

下载本文档

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

文档简介

1、 2 3 4 5 6 7 ,cos 2(7 1) ii x tAft 8 ,1cos 2(72) ii x tAuft 9 % File: c7_sinewave.m f = 1;% frequency of sinusoid fs = 100;% sampling frequency t = (0:200)/fs;% time vector for i=1:20 x(:,i) = cos(2*pi*f*t+rand(1)*2*pi); y(:,i) = cos(2*pi*f*t+rand(1)*pi/2); z(:,i) = (1+rand(1)*cos(2*pi*f*t); end sub

2、plot(3,1,1); plot(t,x,k); ylabel(x(t) subplot(3,1,2); plot(t,y,k); ylabel(y(t) subplot(3,1,3); plot(t,z,k); ylabel(z(t) % End of script file. 10 11 00.511.52 -1 0 1 x(t) 00.511.52 -1 0 1 y(t) 00.511.52 -2 0 2 z(t) 12 00.20.40.60.811.21.41.61.82 -1 0 1 x(t) 00.20.40.60.811.21.41.61.82 -1 0 1 y(t) 00.

3、20.40.60.811.21.41.61.82 -2 0 2 z(t) 13 14 x=random binary(nbits,nsamples)+i*random binary (nbits,nsamples) ; 15 020406080 -1 0 1 Sample Index xd 020406080 -1 0 1 Sample Index xq 16 0100200300400500600700800 -1.5 -1 -0.5 0 0.5 1 1.5 Sample Index xd 0100200300400500600700800 -1.5 -1 -0.5 0 0.5 1 1.5

4、Sample Index xq 17 1 mod( )(73) ii xaxcm 18 19 1 mod( )(74) ii xaxcm 20 21 22 1 1 (714) m a k m 1 ,1,2,3,2(715) i a kim m 23 24 25 26 % File: c7_LCDemo1.m m = 2048; c = 1; seed = 1;% default values of m and c a1 = 65; a2 = 1229;% multiplier values ix1 = seed; ix2 = seed;% initialize algorithm x1 = z

5、eros(1,m); x2 = zeros(1,m); % initialize arrays for i=1:m ix1 = rem(ix1*a1+c),m); x1(i) = ix1/m; ix2 = rem(ix2*a2+c),m); x2(i) = ix2/m; end subplot(1,2,1) y1 = x1(1,2:m),x1(1,1); plot(x1,y1,.)% plot results for a1 subplot(1,2,2) y2 = x2(1,2:m),x2(1,1); plot(x2,y2,.)% plot results for a2 % End of scr

6、ipt file. 2700.51 0 0.2 0.4 0.6 0.8 1 00.51 0 0.2 0.4 0.6 0.8 1 28 2 2 2 1 1 1 (7 19) 1 N n N n NX nX n D NXn 22 22 (720) x DEXYE XEXYa 29 2 1(721)YXZ 2 2222 2 1 12 111(722)DEXXZZ 30 % File: c7_Durbin function D = durbin(x) N = length(x);% length of input vector y = x-mean(x);% remove dc ydiff = y(2

7、:N)-y(1:(N-1);% numerator summand Num = sum(ydiff.*ydiff);% numerator factor of D Den = sum(y.*y);% denominator factor of D D = Num/Den;% Durbin factor % End of function file. 2 222 2 11 (723)D 31 % File: c7_LCDemo2 m = 2048; c = 1; seed = 1; a1 = 65; a2 = 1229; ix1 = 1; ix2 = 1; x1 = zeros(1,m); x2

8、 = zeros(1,m); for i=1:m ix1 = rem(ix1*a1+c),m); x1(i) = ix1; ix2 = rem(ix2*a2+c),m); x2(i) = ix2; end D1 = c7_Durbin(x1); D2 = c7_Durbin(x2); % calculate Durbin parameters rho1 = 1-D1/2; rho2 = 1- D2/2;% calculate correlation text1 = The value of D1 is ,num2str(D1), and rho1 is ,num2str(rho1),.; te

9、xt2 = The value of D2 is ,num2str(D2), and rho2 is ,num2str(rho2),.; disp(text1) disp(text2) % End of script file. 32 c71.CDemo2 The value of D1 is 1.9925 and rhol is 0.0037273. The value of D2 is 1.6037 and rho2 is 0.19814. 33 34 xi+1(16807xi)mod(2147483647) (7-24) ( )cos210000 10000cos210001 10000

10、(725)x ttt 35 1 1 1 171mod 30269(726) 170mod 30307(727) 172mod 30323(728) ii ii ii xx yy zz 36 mod 1(729) 302693030730323 iii i xyz u 16555425264690(730)a 13 30269 30307 303232.7817 10(731)m 37 38 39 40 41 42 (732) X UFX 1 (733) X XFU 43 Pr(734) X FxXx 44 1 PrPr(735) XXX FxFUxUFxFx 45 exp -( ), 0(73

11、6) X fxx u x 1,0 ( )=(737) 0,0 x u x x 0 exp -exp(738) x X Fxy dyx exp(739)XU 46 exp(740)XU 1 ln(741)XU 47 % File: c7_uni2exp clear all% be safe n = input(Enter number of points ); b = 3;% set pdf parameter u = rand(1,n);% generate U y_exp = -log(u)/b;% transformation N_samp,x = hist(y_exp,20);% get

12、 histogram parameters subplot(2,1,1) bar(x,N_samp,1)% plot histogram ylabel(Number of Samples) xlabel(Independent Variable - x) subplot(2,1,2) y = b*exp(-3*x);% calculate pdf del_x = x(3)-x(2);% determine bin width p_hist = N_samp/n/del_x;% probability from histogram plot(x,y,k,x,p_hist,ok)% compare

13、 ylabel(Probability Density) xlabel(Independent Variable - x) legend(true pdf,samples from histogram,1) % End of script file. 48 00.511.52 0 10 20 30 Number of Samples Independent Variable - x 00.511.52 0 1 2 3 Probability Density Independent Variable - x true pdf samples from histogram 49 00.511.52

14、2.53 0 500 1000 Number of Samples Independent Variable - x 00.511.522.53 0 1 2 3 Probability Density Independent Variable - x true pdf samples from histogram 50 2 22 =exp(742) 2 R rr fru r 22 222 0 =expexp(743) 22 r R yyr Frdy 51 2 2 exp(744) 2 R U 2 2 exp(745) 2 R U 2 2ln(746)RU 52 53 02468 0 500 1

15、000 1500 Number of Samples Independent Variable - x 02468 0 0.2 0.4 Probability Density Independent Variable - x true pdf samples from histogram 54 % File: c7_uni2ray clear all% be safe n = input(Enter number of points ); varR = 3;% set pdf parameter u = rand(1,n);% generate U y_exp = sqrt(-2*varR*l

16、og(u);% transformation N_samp,r = hist(y_exp,20);% get histogram parameters subplot(2,1,1) bar(r,N_samp,1)% plot histogram ylabel(Number of Samples) xlabel(Independent Variable - x) subplot(2,1,2) term1 = r.*r/2/varR;% exponent ray = (r/varR).*exp(-term1);% Rayleigh pdf del_r = r(3)-r(2);% determine

17、 bin width p_hist = N_samp/n/del_r;% probability from histogram plot(r,ray,k,r,p_hist,ok)% compare results ylabel(Probability Density) xlabel(Independent Variable - x) legend(true pdf,samples from histogram,1) % End of script file. 55 56 11 Pr(747) iiiiii Pxxxcxx 11 ( )(748) Xiii FxFcxx 1 11 1 Pr(74

18、9) i iij j FXxP 11 ()(750) Xiii FXUFcXx 11 1 (751) ii i XxUF c 57 1 (752) ii FUF 58 for all(753) XX Mgxfx x / ,0 (754) 0, X bM axa Mgx others 59 /max(755) X bM afx 60 61 0 Pr accepted (756) a X i fx dx V ab 11 Pr accepted (757) i V abM 62 11 11 1 Pr +,accepted Pr );% set N fx = zeros(1,N);% array of

19、 output samples u1 = rand(1,N); u2 = rand(1,N);% generate u1 and u2 v1 = R*u1;% generate v1 v2 = (M/R)*rand(1,N);% generate v2 (g(x) kpts = 0;% initialize counter for k=1:N if v2(k)(M/(R*R)*sqrt(R*R-v1(k)*v1(k); kpts=kpts+1;% increment counter fx(kpts)=v1(k); % save output sample end end fx = fx(1:k

20、pts); N_samp,x = hist(fx,20);% get histogram parameters subplot(2,1,1) bar(x,N_samp,1)% plot histogram ylabel(Number of Samples) xlabel(Independent Variable - x) subplot(2,1,2) yt = (M/R/R)*sqrt(R*R-x.*x);% calculate pdf del_x = x(3)-x(2); % determine bin width p_hist = N_samp/kpts/del_x;% probabili

21、ty from histogram plot(x,yt,k,x,p_hist,ok)% compare ylabel(Probability Density) xlabel(Independent Variable - x) legend(true pdf,samples from histogram,3) text = The number of points accepted is ,. num2str(kpts,15), and N is ,num2str(N,15),.; disp(text) % End of script file. 65 02468 0 100 200 Numbe

22、r of Samples Independent Variable - x 02468 0 0.1 0.2 Probability Density Independent Variable - x true pdf samples from histogram 66 02468 0 1000 2000 Number of Samples Independent Variable - x 02468 0 0.1 0.2 Probability Density Independent Variable - x true pdf samples from histogram 67 68 2 2 1

23、( )exp1(761) 22 x X yx FxdyQ 2 exp/2(762) x Q xydy 69 1/2(763) N i i=0 YBU - 70 1/2(764) N i i=0 E YBE U- 2 var1/2(765) i Ux dx 2 var(766) N yi i BU 2 (767) y NB 71 72 (768) y BN (769) 2 y N N 73 74 75 76 22 22 22 22 11 ( , )expexp 2222 1 exp(770) 22 XY xy fx y xy 77 222 (771)xyr 1 tan(772) y x ,(77

24、3) RRXYXY frdAfx y dA cos sin ,(774) XY RXY x r R y r dA frfx y dA 78 /, /, cossin (775) sincos XY R dx drdx dx y dA dy drdy ddAr r r r 2 22 ,exp, 22 0,02(777) R rr fr r 79 22 2 2222 0 expexp, 222 0(778) R rrrr frd r 2 22 0 1 exp, 222 02(779) rr fdr 80 cos(780)XR sin(781)YR 2 12 2lncos2(782)XUU 2 12

25、 2lnsin2(783)YUU 81 % File: c7_boxmul.m function out1,out2=c7_boxmul(N) u1 = rand(1,N);% generate first uniform RV u2 = rand(1,N);% generate second uniform RV ray = sqrt(-2*log(u1);% generate Rayleigh RV out1 = ray.*cos(2*pi*u2);% first Gaussian output out2 = ray.*sin(2*pi*u2);% second Gaussian outp

26、ut % End of function file. 82 83 84 Pr10.2146(784) circle box A reject A 85 86 87 88 89 2 1(785)ZXY 2 22 22222 1 211(786) Z EXY E XE XYE Y 222222 1(787) Z 90 22 (788)E XZ 2 2 (789) XZ XZ E XZ 91 2 0 /2(790) ns N f 2 0 2(791) sn fN 2 ( )( )(792) YX SfH fSf 92 93 2 ( )(793) Y SfH fK ( )/(794) Y H fSfK

27、 94 1 01 1 1 (795) 1 n n n n bb zb z H z a za z 95 0 0 0| (796) /| ff Hf Kfff 96 00.20.40.60.81 0 2 4 6 Normalized Frequency Magnitude Response 00.20.40.60.81 0 2 4 6 Normalized Frequency Magnitude Response 97 2 1/ 1/,| (797) 0, dd ffff S f others 1/4 2 1/,| (798) 0, dd ffff Hf others 98 99 00.020.040.060.08 -0.5 0 0.5 Time Impulse Response -1000-50005001000 0 0.5 1 1.5 x 10 -3 Frequency PSD 100 -5000500 -40 -20 0 Frequency PSD 0.10.150.20.25 -20 -10 0 Time

温馨提示

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

评论

0/150

提交评论