⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 periodogram estimate.m

📁 Generate 100 samples of a zero-mean white noise sequence with variance , by using a uniform random n
💻 M
字号:
%************原题**************************%
%Generate 100 samples of a zero-mean white noise sequence   with variance  , by using a uniform random number generator.
%a 	Compute the autocorrelation of   for  .
%b  Compute the periodogram estimate   and plot it. 
%c  	Generate 10 different realizations of  , and compute the corresponding sample autocorrelation sequences  ,   and  . Compute the average autocorrelation sequence as   and the corresponding periodogram for  .
%d  Compute and plot the average periodogram using the Bartlett method. 
%e  Comment on the results in parts (a) through (d).
w=normrnd(0,1/12^0.5,[1,100]);
%***********a****************%
r=xcorr(w,w)';
for i=1:16
    rxx(i)=r(100-i);
end   
wr=fft(rxx);
for i=1:16
    zr(i)=conj(wr(i))*wr(i);
end
tr=1:1:16;
plot(tr,zr,':')
title('直接法得到的周期图');
%************b***************%
wf=fft(w);
for i=1:100
    zav(i)=conj(wf(i))*wf(i);
end
zav=zav/100;
t=1:1:100;
figure
plot(t,zav,':')
title('间接法得到的周期图');
%************c****************%
for i=1:10
    A(i,:)=normrnd(0,1/12^0.5,[1,100]);
end									%产生10条样本序列
for i=1:10
    a(i,:)=normrnd(0,1/12^0.5,[1,100]);
    ra=xcorr(a(i,:),a(i,:))';
    for j=1:16
        raa(i,j)=ra(100-j);
    end  
end									%分别计算10条样本序列的自相关存在raa数组中
for i=1:10
    sum=zeros(1,16);
    sum=sum+raa(i,:);
end
rav=sum/10;							%计算平均相关函数
ravf=fft(rav);
for i=1:16                           %取模
ravv(i)=(conj(ravf(1,i))*ravf(1,i))^0.5;
end
tt=1:1:16;
figure
plot(tt,ravv)
title('先求平均的间接法');
%*************d*****************%
%分成5块
for i=1:5
	for j=1:20
	ww5(i,j)=w((i-1)*20+j);
	end
end           %分块
for i=1:5
  d5=fft(ww5(i,:));
   for j=1:20
        each5(i,j)=conj(d5(1,j))*d5(1,j);
   end
end               %分别计算每块的周期图
sumeach5=zeros(1,20);
for i=1:5
    sumeach5=sumeach5+each5(i,:);
end
sumave5=sumeach5/20;  %平均周期图
td5=1:1:20;
figure
plot(td5,sumave5)
title('平均周期图法,5块'); 
%分成10块
for i=1:10
	for j=1:10
	ww10(i,j)=w((i-1)*10+j);
	end
end           %分块
for i=1:10
  d10=fft(ww10(i,:));
   for j=1:10
        each10(i,j)=conj(d10(1,j))*d10(1,j);
   end
end               %分别计算每块的周期图
sumeach10=zeros(1,10);
for i=1:10
    sumeach10=sumeach10+each10(i,:);
end
sumave10=sumeach10/10;  %平均周期图
td10=1:1:10;
figure
plot(td10,sumave10)
title('平均周期图法,10块'); 
%分成20块
for i=1:20
	for j=1:5
	ww20(i,j)=w((i-1)*5+j);
	end
end           %分块
for i=1:20
  d20=fft(ww20(i,:));
   for j=1:5
        each20(i,j)=conj(d20(1,j))*d20(1,j);
   end
end               %分别计算每块的周期图
sumeach20=zeros(1,5);
for i=1:20
    sumeach20=sumeach20+each20(i,:);
end
sumave20=sumeach20/5;  %平均周期图
td20=1:1:5;
figure
plot(td20,sumave20)
title('平均周期图法,20块'); 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -