📄 fig7_10.m
字号:
% Figure 7.10
%
% A 1024-sample realisation of uniformly distributed white noise sequence.
% First 51 samples are displayed.
% Probability density function, autocorrelation and power spectral density
% are estimated from the 1024 samples.
%
% BM
% June 1998
clear
clf
colordef(1,'black')
% generate data
M = 1024;
x = rand(1,M)-0.5;
% estimate pdf
[nn,xx] = hist(x);
dx = xx(2)-xx(1);
pdf = nn/M/dx;
% pad with zeros for plotting
xx = [ xx(1)-2*dx xx(1)-dx xx xx(10)+dx xx(10)+2*dx ];
pdf = [ 0 0 pdf 0 0 ];
% autocorrelation estimate
x = x - mean(x);
xxx = xcorr(x)/M;
lag = -5:5;
phixx = xxx(M+lag);
% power spectral density estimate
NFFT = 32;
sxx = psd(x,NFFT,'none');
f = (-NFFT/2:NFFT/2)/NFFT;
sxx = [ fliplr( sxx(2:NFFT/2+1)' ) sxx' ];
subplot(221)
N = 50;
rr = 1:N+1;
t = 0:N;
stem(t,x(rr)),xlabel('sample no.'),ylabel('\itx(n)'),title('(a) one realisation')
axis( [ 0 N -0.6 0.6 ] )
subplot(222)
plot(xx,pdf),xlabel('\itx'),ylabel('\itp(x)'),title('(b) pdf estimate')
grid
axis ( [ -0.6 0.6 0 1.2 ])
subplot(223)
stem(lag,phixx),xlabel('\itm'),ylabel('{\phi}_{\itxx}\it(m)'),title('(c) autocorrelation estimate')
grid
axis ( [ -6 6 -0.05 0.1 ] )
subplot(224)
plot(f,sxx),xlabel('\omega'),ylabel('{\itS}_f{\itxx}(\omega)'),title('(d) PSD estimate')
grid
axis ( [ -0.5 0.5 0 0.1 ] )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -