算法程序clearclcN=500;M=300;u=0.1;n=1:(N+1);a=[-0.98 0.98]for k=1:2for j=1:Mvn=randn(1,N);a1=[1 a(k)];b1=1;xn=filter(b1,a1,vn);d=var(xn);xn=xn/sqrt(d);fn(1)=xn(1);wn(1)=0;wn(2)=wn(1);for i=2:length(xn)fn(i)=xn(i)-wn(i)*xn(i-1);wn(i+1)=wn(i)+u*xn(i-1)*fn(i);end;wm(j,:)=wn;end;w(k,:)=wn;ew(k,:)=mean(wm);end;plot(n,w(1,:),n,ew(1,:),n,w(2,:),n,ew(2,:));clearclcN=500;M=300;u=0.2;n=1:N;a=[0.98 -0.98]k=1;for j=1:Mvn=randn(1,N);a1=[1 a(k)];b1=1;xn=filter(b1,a1,vn);d=var(xn);xn=xn/sqrt(d);fn(1)=xn(1);wn(1)=0;wn(2)=wn(1);for i=2:length(xn)fn(i)=xn(i)-wn(i)*xn(i-1);wn(i+1)=wn(i)+u*xn(i-1)*fn(i);f2(i)=fn(i)^2;end;fm(j,:)=f2;end;fw=mean(fm);semilogy(n,f2,n,fw);clearclcN=500;M=300;u=[0.1 0.05 0.02];n=1:N;a=[-0.99 0.99]k=1;for l=1:3for j=1:Mvn=randn(1,N);a1=[1 a(k)];b1=1;xn=filter(b1,a1,vn);d=var(xn);xn=xn/sqrt(d);fn(1)=xn(1);wn(1)=0;wn(2)=wn(1);for i=2:length(xn)fn(i)=xn(i)-wn(i)*xn(i-1);wn(i+1)=wn(i)+u(l)*xn(i-1)*fn(i); f2(i)=fn(i)^2;end;fm(j,:)=f2;end;fw(l,:)=mean(fm);end;semilogy(n,fw(1,:),n,fw(2,:),n,fw(3,:));clearN = 100;clearN = 1000;t = 0:10/N:10-10/N;zt = 60*(pdf('Normal', t-8, 0, 0.3) + pdf('Normal', t, 0, 0.8))+rand(1,1000)*3;figure(1);x = 0:100/1000:100-100/1000;plot(x,zt);[X,Y]=meshgrid(-5:0.1:10,-5:0.1:10);xy = [X(:) Y(:)];p=mvnpdf(xy,[],[]); P=reshape(p,size(X));[X,Y]=meshgrid(-10:0.1:5,-5:0.1:10);xy = [X(:) Y(:)];p1=mvnpdf(xy,[],[]); P1=reshape(p1,size(X));X = 0:160/100:160;Y = 0:160/150:160;PS = P/3+P1;PS = (PS(:,50:150) + randn(151,101)/500)*600;figure(2);surf(X,Y,PS);axis tight能量检测%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%生成调制信号fs=100;%采样频率fc=40;%载频fo=fs/20;%码率L=300;%信号样本t = (0:L-1)*1/fs;xn=cos(8*pi*fc*t);y = xn + randn(size(t));figure(1)plot(t,y) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%进行能量检测NFFT = 2^nextpow2(L);Y = fft(y,NFFT)/L;f = fs/2*linspace(0,1,NFFT/2);figure(2)plot(f,2*abs(Y(1:NFFT/2)))程序代码相当全面clearN = 100;clearN = 1000;t = 0:10/N:10-10/N;zt = 60*(pdf('Normal', t-8, 0, 0.3) + pdf('Normal', t, 0, 0.8))+rand(1,1000)*3;figure(1);x = 0:100/1000:100-100/1000;plot(x,zt);[X,Y]=meshgrid(-5:0.1:10,-5:0.1:10);xy = [X(:) Y(:)];p=mvnpdf(xy,[],[]); P=reshape(p,size(X));[X,Y]=meshgrid(-10:0.1:5,-5:0.1:10);xy = [X(:) Y(:)];p1=mvnpdf(xy,[],[]); P1=reshape(p1,size(X));X = 0:160/100:160;Y = 0:160/150:160;PS = P/3+P1;PS = (PS(:,50:150) + randn(151,101)/500)*600;figure(2);surf(X,Y,PS);axis tight%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%生成调制信号fs=100;%采样频率fc=40;%载频fo=fs/20;%码率L=300;%信号样本t = (0:L-1)*1/fs;xn=cos(8*pi*fc*t);y = xn + randn(size(t));figure(1)plot(t,y) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%进行能量检测NFFT = 2^nextpow2(L);Y = fft(y,NFFT)/L;f = fs/2*linspace(0,1,NFFT/2);figure(2)plot(f,2*abs(Y(1:NFFT/2)))%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%生成bpsk调制信号fs=100;%采样频率fc=40;%载频fo=fs/20;%码率a=2*fo;%循环周期T=40;%信号样本x=rand(40,1);y=round(x);a1=y*2-1;z=ones(200,1);for i=1:40for j=1:5an(5*i-5+j)=z(5*i-5+j)*a1(i);endendt=1/fs:1/fs:2;xn=an.*cos(4*pi*fc*t);figure(1)plot(t,xn);axis([0 2 -1.5 1.5]); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%进行周期图检测window=kaiser(length(xn),0.5);%矩形窗nfft=512;%512fft[Pxx,f]=periodogram(xn,window,nfft,fs);%周期图检测%%%%%%%%%(生成一段加噪信号)as=rand(20,1);b=as*2;c=floor(b);d=reshape(c,10,2);e=bi2de(d,'left-msb');h=modem.qammod(4);g=modulate(h,e);scatterplot(g);%生成一段随机4QAM信号N=length(g);x=real(g);y=imag(g);fc=40;%载波频率,有线电视信号t0=0.000001;ts=1e-010;t1=0:ts:t0;n1=0.1*randn(1,N);for i=1:Ns1=x(i)*cos(2*pi*fc*t1)-y(i)*sin(2*pi*fc*t1); end%生成4QAM调制后信号%加入噪声ntt2=0.000001:1e-010:0.000002;M1=length(t2);nt=0.1*randn(1,M1);s2=nt.*cos(2*pi*fc*t2);%add ntt=0:ts:0.000002;s=zeros(1,20001);for i=1:10001s(i)=s1(i);endfor j=1:10000s(j+10000)=s2(j);end%加入间隔无信号时间%生成调制后信号%%%%%%%%%%%%%%%%%%%%%%(1)取有用信号时间段,计算函数值cl=xcorr(s1);L=length(cl);i2=1:2:L;c2=cl(i2);%自相关函数a1=fc;%循环周期%构造积分对象ppp=exp(-2*pi*t1*j);M=length(p);pp=c2.*p;%进行无穷大积分ts=1e-010;cxx1=pp*ts;u1=sum(cxx1(1:10),'double');%加入统计频率周期a2N1=length(c2);N2=length(t);f1=60e6;%采样时间Te=0.03;i3=1:N1;a2=i3./(N1*Te);tj1=exp(a2);cx1=tj1*u1*1e10;U1=sum(cx1(1:10));%%%%%%%%%%%%%%%%%%%%%%(2)取噪声时间段,计算函数值cl2=xcorr(s2);L=length(cl2);i3=1:2:L;c22=cl2(i3);p2=exp(-2*pi*t2*j);M2=length(p);pp2=c22.*p2;%进行无穷大积分ts=1e-010;cxx2=pp2*ts;u2=sum(cxx2(1:10),'double');%加入统计频率周期a2i3=1:N1;a2=i3./(N1*Te);tj2=exp(a2);cx2=tj2*u2*1e10;U2=sum(cx2(1:10));%检测完毕%%%%%%%%%%%%%%%%%%% 输出检测示意图;tz=0:ts:0.000002;sz=zeros(1,20001);for i=1:10001sz(i)=U1;endfor j=1:10000sz(j+10000)=U2;end%%%%%%%%(检测完成,输出图谱)figure(2)plot(f,-10*log10(Pxx));window=kaiser(length(xn),0.5);nfft=1024; %%%%%%%%%%%%%%%%%%%%%%%%%%%%1024fft[Pxx,f]=periodogram(xn,window,nfft,fs);%周期图检测figure(3)plot(f,-10*log10(Pxx)); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%对不同类型窗函数进行检测性能分析window1=boxcar(length(xn));%矩形窗window2=hamming(length(xn));%海明窗window3=blackman(length(xn));%blackman窗[Pxx1,f]=periodogram(xn,window1,nfft,fs); [Pxx2,f]=periodogram(xn,window2,nfft,fs); [Pxx3,f]=periodogram(xn,window3,nfft,fs); figure(4)subplot(221)plot(f,-10*log10(Pxx));subplot(222)plot(f,-10*log10(Pxx1));subplot(223)plot(f,-10*log10(Pxx2));subplot(224)plot(f,-10*log10(Pxx3));。