- 3
- 0
- 约 8页
- 2017-09-02 发布于浙江
- 举报
白噪声matlab
均匀分布的白噪声信号u(n),画出其波形,并检验其分布情况
%-----------------------------------------------------------------
% To test rand.m and to generate the white noise signal u(n)
% with uniform distribution
% 产生均匀分布的随机白噪信号,并观察数据分布的直方图
%-----------------------------------------------------------------
clear;
N=50000;
u=rand(1,N);
u_mean=mean(u)
power_u=var(u)
subplot(211)
plot(u(1:100));grid on;
ylabel(u(n))
xlabel(n)
subplot(212)
hist(u,50);grid on;
ylabel(histogram of u(n))
思考:如何产生一均匀分布、均值为0,功率为0.01的白噪声信号u(n)
提示:u(n)~[a,b]上均匀分布,E(u)= (a+b)/2,
% to generate the white noise signal u(n) with uniform distribution
% and power p;
% 产生均匀分布的白噪信号,使均值为0,功率为p
%-----------------------------------------------------------------
clear;
p=0.01;
N=50000;
u=rand(1,N);
u=u-mean(u);
a=sqrt(12*p);
u1=u*a;
power_u1=dot(u1,u1)/N
subplot(211)
plot(u1(1:200));grid on;
ylabel(u(n))
xlabel(n)
example2: 产生零均值功率0.1且服从高斯分布的白噪声
%-----------------------------------------------------------------
% to test randn.m and to generate the white noise signal u(n)
% with Gaussian distribution and power p
% 产生高斯分布的白噪信号,使功率为p,并观察数据分布的直方图
%-----------------------------------------------------------------
clear;
p=0.1;
N=500000;
u=randn(1,N);
a=sqrt(p)
u=u*a;
power_u=var(u)
subplot(211)
plot(u(1:200));grid on;
ylabel(u(n));
xlabel(n)
subplot(212)
hist(u,50);grid on;
ylabel(histogram of u(n));
example3: sinc信号
%-----------------------------------------------------------------
% to generate the sinc function.
% 产生一 sinc 函数;
%-----------------------------------------------------------------
clear;
n=200;
stept=4*pi/n;
t=-2*pi:stept:2*pi;
y=sinc(t);
plot(t,y,t,zeros(size(t)));
ylabel(sinc(t));
xlabel(t=-2*pi~2*pi);
grid on;
example4: chirp信号
%-----------------------------------------------------------------
% to test chirp.m and to generate the chirp signal x(t)
% 产生一 chirp 信号;
% chirp(T0,F0,T1,F1):
% T0: 信号的开
原创力文档

文档评论(0)