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

下载本文档

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

文档简介

1、234 56 7,cos 2(7 1)iix tAft8,1cos 2(72)iix tAuft9% File: c7_sinewave.mf = 1;% frequency of sinusoidfs = 100;% sampling frequencyt = (0:200)/fs;% time vectorfor 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);endsubplot(3,1,1); plot(t

2、,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-101x(t)00.511.52-101y(t)00.511.52-202z(t)1200.20.40.60.811.21.41.61.82-101x(t)00.20.40.60.811.21.41.61.82-101y(t)00.20.40.60.811.21.41.61.82-202z(t)13 14x=random bin

3、ary(nbits,nsamples)+i*random binary (nbits,nsamples) 101Sample Indexxd020406080-101Sample Indexxq160100200300400500600700800-1.5-1-0.500.511.5Sample Indexxd0100200300400500600700800-1.5-1-0.500.511.5Sample Indexxq171mod( )(73)iixaxcm18191mod( )(74)iixaxcm20 212211(714)makm 1,1,2,3,2(715

4、)iakimm 23242526% File: c7_LCDemo1.mm = 2048; c = 1; seed = 1;% default values of m and ca1 = 65; a2 = 1229;% multiplier valuesix1 = seed; ix2 = seed;% initialize algorithmx1 = zeros(1,m); x2 = zeros(1,m); % initialize arraysfor i=1:m ix1 = rem(ix1*a1+c),m); x1(i) = ix1/m; ix2 = rem(ix2*a2+c),m); x2

5、(i) = ix2/m;endsubplot(1,2,1)y1 = x1(1,2:m),x1(1,1);plot(x1,y1,.)% plot results for a1subplot(1,2,2)y2 = x2(1,2:m),x2(1,1);plot(x2,y2,.)% plot results for a2% End of script file.2700.5100.20.40.60.8100.5100.20.40.60.812822211 1(7 19)1 NnNnNX nX nDNXn2222(720)xDEXYE XEXYa2921(721)YXZ222222112 111(722

6、)DEXXZZ30% File: c7_Durbinfunction D = durbin(x)N = length(x);% length of input vectory = x-mean(x);% remove dcydiff = y(2:N)-y(1:(N-1);% numerator summandNum = sum(ydiff.*ydiff);% numerator factor of D Den = sum(y.*y);% denominator factor of DD = Num/Den;% Durbin factor% End of function file.222221

7、1(723)D 31% File: c7_LCDemo2m = 2048; c = 1; seed = 1;a1 = 65; a2 = 1229;ix1 = 1; ix2 = 1;x1 = zeros(1,m); x2 = 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;endD1 = c7_Durbin(x1); D2 = c7_Durbin(x2); % calculate Durbin parametersrho1 = 1-D1/2; rho2 =

8、1- D2/2;% calculate correlationtext1 = The value of D1 is ,num2str(D1), and rho1 is ,num2str(rho1),.;text2 = The value of D2 is ,num2str(D2), and rho2 is ,num2str(rho2),.; disp(text1)disp(text2)% End of script file.32c71.CDemo2The value of D1 is 1.9925 and rhol is 0.0037273.The value of D2 is 1.6037

9、 and rho2 is 0.19814.3334 xi+1(16807xi)mod(2147483647) (7-24) ( )cos210000 10000cos210001 10000(725)x ttt35111171mod 30269(726)170mod 30307(727)172mod 30323(728)iiiiiixxyyzz36 mod 1(729)302693030730323iiiixyzu16555425264690(730)a 1330269 30307 303232.7817 10(731)m 37 3839404142(732)XUFX 1(733)XXFU43

10、 Pr(734)XFxXx44 1PrPr(735)XXXFxFUxUFxFx45 exp -( ), 0(736)Xfxx u x1,0( )=(737)0,0 xu xx 0exp -exp(738)xXFxy dyxexp(739)XU 46exp(740)XU 1ln(741)XU 47% File: c7_uni2expclear all% be safen = input(Enter number of points );b = 3;% set pdf parameteru = rand(1,n);% generate Uy_exp = -log(u)/b;% transforma

11、tionN_samp,x = hist(y_exp,20);% get histogram parameterssubplot(2,1,1)bar(x,N_samp,1)% plot histogramylabel(Number of Samples)xlabel(Independent Variable - x)subplot(2,1,2)y = b*exp(-3*x);% calculate pdfdel_x = x(3)-x(2);% determine bin widthp_hist = N_samp/n/del_x;% probability from histogramplot(x

12、,y,k,x,p_hist,ok)% compareylabel(Probability Density)xlabel(Independent Variable - x)legend(true pdf,samples from histogram,1) % End of script file.4800.511.520102030Number of SamplesIndependent Variable - x00.511.520123Probability DensityIndependent Variable - xtrue pdfsamples from histogram4900.51

13、1.522.5305001000Number of SamplesIndependent Variable - x00.511.522.530123Probability DensityIndependent Variable - xtrue pdfsamples from histogram50 222=exp(742)2Rrrfru r 222220=expexp(743)22rRyyrFrdy5122exp(744)2RU22exp(745)2RU22ln(746)RU525302468050010001500Number of SamplesIndependent Variable -

14、 x0246800.20.4Probability DensityIndependent Variable - xtrue pdfsamples from histogram54% File: c7_uni2rayclear all% be safen = input(Enter number of points );varR = 3;% set pdf parameteru = rand(1,n);% generate Uy_exp = sqrt(-2*varR*log(u);% transformationN_samp,r = hist(y_exp,20);% get histogram

15、parameterssubplot(2,1,1)bar(r,N_samp,1)% plot histogramylabel(Number of Samples)xlabel(Independent Variable - x)subplot(2,1,2)term1 = r.*r/2/varR;% exponentray = (r/varR).*exp(-term1);% Rayleigh pdfdel_r = r(3)-r(2);% determine bin widthp_hist = N_samp/n/del_r;% probability from histogramplot(r,ray,

16、k,r,p_hist,ok)% compare resultsylabel(Probability Density)xlabel(Independent Variable - x)legend(true pdf,samples from histogram,1)% End of script file.555611Pr(747)iiiiiiPxxxcxx11( )(748)XiiiFxFcxx1111Pr(749)iiijjFXxP11()(750)XiiiFXUFcXx111(751)iiiXxUFc571(752)iiFUF58 for all(753)XXMgxfx x / ,0(754

17、)0,XbM axaMgxothers59 /max(755)XbM afx 6061 0Pr accepted (756)aXifx dxVab11Pr accepted (757)iVabM62 11111Pr +,accepted Pr );% set Nfx = zeros(1,N);% array of output samplesu1 = rand(1,N); u2 = rand(1,N);% generate u1 and u2v1 = R*u1;% generate v1v2 = (M/R)*rand(1,N);% generate v2 (g(x)kpts = 0;% ini

18、tialize counterfor 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 endendfx = fx(1:kpts);N_samp,x = hist(fx,20);% get histogram parameterssubplot(2,1,1)bar(x,N_samp,1)% plot histogramylabel(Number of Samples)xlabel(Independent Variabl

19、e - x)subplot(2,1,2)yt = (M/R/R)*sqrt(R*R-x.*x);% calculate pdfdel_x = x(3)-x(2); % determine bin widthp_hist = N_samp/kpts/del_x;% probability from histogramplot(x,yt,k,x,p_hist,ok)% compareylabel(Probability Density)xlabel(Independent Variable - x)legend(true pdf,samples from histogram,3)text = Th

20、e number of points accepted is ,. num2str(kpts,15), and N is ,num2str(N,15),.;disp(text) % End of script file.65024680100200Number of SamplesIndependent Variable - x0246800.10.2Probability DensityIndependent Variable - xtrue pdfsamples from histogram6602468010002000Number of SamplesIndependent Varia

21、ble - x0246800.10.2Probability DensityIndependent Variable - xtrue pdfsamples from histogram6768221( )exp1(761)22xXyxFxdyQ 2exp/2(762)xQ xydy691/2(763)Nii=0YBU -70 1/2(764)Nii=0E YBE U- 2var1/2(765)iUx dx2var(766)NyiiBU 2(767)yNB7172(768)yBN(769)2yNN737475762222222211( , )expexp22221exp(770)22XYxyfx

22、 yxy77222(771)xyr1tan(772)yx,(773)RRXYXYfrdAfx y dA cossin,(774)XYRXYx rRy rdAfrfx y dA78/,/,cossin(775)sincosXYRdx drdx dx ydAdy drdy ddArrr r222,exp,220,02(777)Rrrfrr 79 22222220expexp,2220(778)Rrrrrfrdr 22201exp,22202(779)rrfdr 80cos(780)XR sin(781)YR 2122lncos2(782)XUU 2122lnsin2(783)YUU 81% Fil

23、e: c7_boxmul.mfunction out1,out2=c7_boxmul(N)u1 = rand(1,N);% generate first uniform RVu2 = rand(1,N);% generate second uniform RVray = sqrt(-2*log(u1);% generate Rayleigh RVout1 = ray.*cos(2*pi*u2);% first Gaussian outputout2 = ray.*sin(2*pi*u2);% second Gaussian output% End of function file.828384

24、Pr10.2146(784)circleboxAreject A 858687888921(785)ZXY 222222221211(786)ZEXYE XE XYE Y 2222221(787)Z 902(788)E XZ 22(789)XZXZE XZ 9120/2(790)nsN f 202(791)snfN 2( )( )(792)YXSfH fSf 9293 2( )(793)YSfH fK ( )/(794)YH fSfK 94 10111(795)1nnnnbb zb zH z a za z95 000|(796)/|ffHf Kfff9600.20.40.60.810246Normalized FrequencyMagnitude Response00.20.40.60.810246Normalized FrequencyMagnitude Response97 21/ 1/,|(797)0,ddffffS f others 1/421/,|(798)0,ddffffHf others989900.020.040.060.08-0.500.5TimeImpulse Response-1000-5000500100000.511.5x 10-3FrequencyPSD100-5000500-40-200FrequencyPSD0

温馨提示

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

评论

0/150

提交评论