白噪声的测试MATLAB程序
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
白噪声的测试MATLAB程序
学术篇 2009-11-13 22: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]=ksden sity(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(c or4,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([0 511 0 10]);
subplot(3,2,2),plot(f,log10(p2(1:512)));title('正态分布');%axis([0 511 0 10]); subplot(3,2,3),plot(f,log10(p3(1:512)));title('指数分布');%axis([0 511 0 10]); subplot(3,2,4),plot(f,log10(p4(1:512)));title('瑞利分布');%axis([0 511 0 10]); subplot(3,2,5),plot(f,log10(p5(1:512)));title('K方分布');%axis([0 511 0 10]); %时域,频域特性曲线
%时域特性曲线:
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([0 1023 0 50]);title('均匀分布幅频特性'); subplot(3,2,2),plot(abs(f2));title('正态分布');
subplot(3,2,3),plot(abs(f3)),axis([0 1023 0 200]);title('指数分布');
subplot(3,2,4),plot(abs(f4)),axis([0 1023 0 50]);title('瑞利分布');
subplot(3,2,5),plot(abs(f5)),axis([0 1023 0 100]);title('K方分布');
%相频特性曲线%%%%%%%%%%%%%%%
figure(7);