白噪声的测试MATLAB程序

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

白噪声的测试MATLAB程序学术篇2009-11-1322:18:03阅读232评论0字号:大中小订阅clear;clc;%生成各种分布的随机数x1=unifrnd(-1,1,1,1024);%生成长度为1024的均匀分布x2=normrnd(0,1,1,1024);%生成长度为1024的正态分布x3=exprnd(1,1,1024);%生成长度为1024的指数分布均值为零x4=raylrnd(1,1,1024);%生成长度为1024的瑞利分布x5=chi2rnd(1,1,1024);%生成长度为1024的kaifang分布%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%求各种分布的均值m1=mean(x1),m2=mean(x2),m3=mean(x3),m4=mean(x4),m5=mean(x5)%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%求各种分布的方差v1=var(x1),v2=var(x2),v3=var(x3),v4=var(x4),v5=var(x5)%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%求各种分布的自相关函数figure(1);title('自相关函数图');cor1=xcorr(x1);cor2=xcorr(x2);cor3=xcorr(x3);cor4=xcorr(x4);cor5=xcorr(x5);subplot(3,2,1),plot(1:2047,cor1);title('均匀分布自相关函数图');subplot(3,2,2),plot(1:2047,cor2);title('正态分布');subplot(3,2,3),plot(1:2047,cor3);title('指数分布');subplot(3,2,4),plot(1:2047,cor4);title('瑞利分布');subplot(3,2,5),plot(1:2047,cor5);title('K方分布');%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%求各种分布的概率密度函数y1=unifpdf(x1,-1,1);y2=normpdf(x2,0,1);y3=exppdf(x3,1);y4=raylpdf(x4,1);y5=chi2pdf(x5,1);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%各种分布的频数直方图figure(2);subplot(3,2,1),hist(x1);title('均匀分布频数直方图');subplot(3,2,2),hist(x2,[-4:0.1:4]);title('正态分布');subplot(3,2,3),hist(x3,[0:.1:20]);title('指数分布');subplot(3,2,4),hist(x4,[0:0.1:4]);title('瑞利分布');subplot(3,2,5),hist(x5,[0:0.1:10]);title('K方分布');%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%各种分布的概率密度估计figure(3);[k1,n1]=ksdensity(x1);[k2,n2]=ksdensity(x2);[k3,n3]=ksdensity(x3);[k4,n4]=ksdensity(x4);[k5,n5]=ksdensity(x5);subplot(3,2,1),plot(n1,k1);title('均匀分布概率密度');subplot(3,2,2),plot(n2,k2);title('正态分布');subplot(3,2,3),plot(n3,k3);title('指数分布');subplot(3,2,4),plot(n4,k4);title('瑞利分布');subplot(3,2,5),plot(n5,k5);title('K方分布');%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%功率谱密度%plot(abs(fft(cor2,2^18)));plot(fft(cor2,2^18));plot(fft(cor3,2^18));plot(fft(cor4,2^18));plot(fft(cor5,2^18));figure(4);f1=fft(x1,1024);f2=fft(x2,1024);f3=fft(x3,1024);f4=fft(x4,1024);f5=fft(x5,1024);p1=f1.*conj(f1)/1024;p2=f2.*conj(f2)/1024;p3=f3.*conj(f3)/1024;p4=f4.*conj(f4)/1024;p5=f5.*conj(f5)/1024;f=1000*(0:511)/1024;subplot(3,2,1),plot(f,log10(p1(1:512)));title('均匀分布功率谱密度');%axis([0511010]);subplot(3,2,2),plot(f,log10(p2(1:512)));title('正态分布');%axis([0511010]);subplot(3,2,3),plot(f,log10(p3(1:512)));title('指数分布');%axis([0511010]);subplot(3,2,4),plot(f,log10(p4(1:512)));title('瑞利分布');%axis([0511010]);subplot(3,2,5),plot(f,log10(p5(1:512)));title('K方分布');%axis([0511010]);%时域,频域特性曲线%时域特性曲线:figure(5);subplot(3,2,1),plot(1:1024,x1);title('均匀分布时域特性曲线');subplot(3,2,2),plot(1:1024,x2);title('正态分布');subplot(3,2,3),plot(1:1024,x3);title('指数分布');subplot(3,2,4),plot(1:1024,x4);title('瑞利分布');subplot(3,2,5),plot(1:1024,x5);title('K方分布');%幅频特性曲线%%%%%%%%%%%%%%%figure(6);subplot(3,2,1),plot(abs(f1)),axis([01023050]);title('均匀分布幅频特性');subplot(3,2,2),plot(abs(f2));title('正态分布');subplot(3,2,3),plot(abs(f3)),axis([010230200]);title('指数分布');subplot(3,2,4),plot(abs(f4)),axis([01023050]);title('瑞利分布');subplot(3,2,5),plot(abs(f5)),axis([010230100]);title('K方分布');%相频特性曲线%%%%%%%%%%%%%%%figure(7);subplot(3,2,1),plot(angle(f1));title('均匀分布相频特性');subplot(3,2,2),plot(angle(f2));title('正态分布');subplot(3,2,3),plot(angle(f3));title('指数分布');subplot(3,2,4),plot(angle(f4));title('瑞利分布');subplot(3,2,5),plot(angle(f5));title('K方分布');%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%随机数长度为10240时figure(8);x11=unifrnd(-1,1,1,10240);%生成长度为10240的均匀分布x22=normrnd(0,1,1,10240);%生成长度为10240的正态分布x33=exprnd(1,1,10240);%生成长度为10240的指数分布x44=raylrnd(1,1,10240);%生成长度为10240的瑞利分布x55=chi2rnd(1,1,10240);%生成长度为10240的kaifang分布f11=fft(x11,10240);f22=fft(x22,10240);f33=fft(x33,10240);f44=fft(x44,10240);f55=fft(x55,10240);p11=f11.*conj(f11)/10240;p22=f22.*conj(f22)/10240;p33=f33.*conj(f33)/10240;p44=f44.*conj(f44)/10240;p55=f55.*conj(f55)/10240;ff=10000*(0:5119)/10240;subplot(3,2,1),plot(ff,log10(p11(1:5120))),title('均匀分布功率谱密度');subplot(3,2,2),plot(ff,log10(p22(1:5120))),title('正态分布');subplot(3,2,3),plot(ff,log10(p33(1:5120))),title('指数分布');subplot(3,2,4),plot(ff,log10(p44(1:5120))),title('瑞利分布');subplot(3,2,5),plot(ff,log10(p55(1:5120))),title('K方分布');figure;cor11=xcorr(x11);cor22=xcorr(x22);cor33=xcorr(x33);cor44=xcorr(x44);cor55=xcorr(x55);subplot(3,2,1),plot(cor11);title('均匀分布自相关函数图');subplot(3,2,2),plot(cor22);title('正态分布');subplot(3,2,3),plot(cor33);title('指数分布');subplot(3,2,4),plot(cor44);title('瑞利分布');subplot(3,2,5),plot(cor55);title('K方分布');%vp1=var(p1),vp11=var(p11),vp2=var(p2),vp22=var(p22),vp3=var(p3),vp33=var(p33),vp4=var(p4),vp44=var(p44),vp5=var(p5),vp55=var(p55)%判断是否是高斯分布%%%%%%%%%%%%%%%%%%%%%%%%%%s=zeros(1,1024);fori=0:4z=unifrnd(0,1,1,1024);s=s+z;ends1=zeros(1,1024);forj=0:4z1=exprnd(3,1,1024);s1=s1+z1;endfigure;[j1,l1]=ksdensity(s);[j2,l2]=ksdensity(s1);subplot(2,2,1),hist(s);title('均匀分布叠加');subplot(2,2,2),plot(l1,j1);title('均匀分布叠加');subplot(2,2,3),hist(s1);title('指

1 / 4
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功