现代数字信号处理及应用仿真题答案

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

仿真作业姓名:李亮学号:S1301010834.17程序clc;clear;fori=1:500sigma_v1=0.27;b(1)=-0.8458;b(2)=0.9458;a(1)=-(b(1)+b(2));a(2)=b(1)*b(2);datlen=500;rand('state',sum(100*clock));s=sqrt(sigma_v1)*randn(datlen,1);x=filter(1,[1,a],s);%%sigma_v2=0.1;u=x+sqrt(sigma_v2)*randn(datlen,1);d=filter(1,[1,-b(1)],s);%%w0=[1;0];w=w0;M=length(w0);N=length(u);mu=0.005;forn=M:Nui=u(n:-1:n-M+1);y(n)=w'*ui;e(n)=d(n)-y(n);w=w+mu.*conj(e(n)).*ui;w1(n)=w(1);w2(n)=w(2);ee(:,i)=mean(e.^2,2);endendep=mean(ee');plot(ep);xlabel('迭代次数');ylabel('MSE');title('学习曲线');plot(w1);hold;plot(w2);仿真结果:步长0.015仿真结果05010015020025030035040045050000.10.20.30.40.50.60.7迭代次数MSE学习曲线步长0.025仿真结果步长0.005仿真结果4.18程序data_len=512;%样本序列的长度trials=100;%随机试验的次数A=zeros(data_len,2);EA=zeros(data_len,1);B=zeros(data_len,2);EB=zeros(data_len,1);form=1:trialsa1=-0.975;a2=0.95;sigma_v_2=0.0731;v=sqrt(sigma_v_2)*randn(data_len,1,trials);%产生v(n)u0=[00];num=1;den=[1a1a2];Zi=filtic(num,den,u0);%滤波器的初始条件u=filter(num,den,v,Zi);%产生样本序列u(n)%(2)用LMS滤波器来估计w1和w2mu1=0.05;mu2=0.005;w1=zeros(2,data_len);w2=zeros(2,data_len);e1=zeros(data_len,1);e2=zeros(data_len,1);d1=zeros(data_len,1);d2=zeros(data_len,1);%LMS迭代过程forn=3:data_len-1w1(:,n+1)=w1(:,n)+mu1*u(n-1:-1:n-2,:,m)*conj(e1(n));w2(:,n+1)=w2(:,n)+mu2*u(n-1:-1:n-2,:,m)*conj(e2(n));d1(n+1)=w1(:,n+1)'*u(n:-1:n-1,:,m);d2(n+1)=w2(:,n+1)'*u(n:-1:n-1,:,m);e1(n+1)=u(n+1,:,m)-d1(n+1);e2(n+1)=u(n+1,:,m)-d2(n+1);endA=A+conj(w1)';EA=EA+e1.^2;B=B+conj(w2)';EB=EB+e2.^2;end%剩余均方误差和失调参数wopt=zeros(2,trials);Jmin=zeros(1,trials);sum_eig=zeros(trials,1);form=1:trials;rm=xcorr(u(:,:,m),'biased');R=[rm(512),rm(513);rm(511),rm(512)];p=[rm(511);rm(510)];wopt(:,m)=R\p;[v,d]=eig(R);Jmin(m)=rm(512)-p'*wopt(:,m);sum_eig(m)=d(1,1)+d(2,2);endsJmin=sum(Jmin)/trials;e1_100trials_ave=sum(e1)/trials;e2_100trials_ave=sum(e2)/trials;Jex1=e1_100trials_ave-sJmin;Jex2=e2_100trials_ave-sJmin;sum_eig_100trials=sum(sum_eig)/100;Jexfin=mu1*sJmin*(sum_eig_100trials/(2-mu1*sum_eig_100trials));Jexfin2=mu2*sJmin*(sum_eig_100trials/(2-mu2*sum_eig_100trials));M1=Jexfin/sJminM2=Jexfin2/sJminfigure(1);plot(A/trials);holdon;plot(conj(w1)');xlabel('迭代次数');ylabel('权向量');title('步长为0.05权向量收敛曲线');figure(2);plot(B/trials);holdon;plot(conj(w2)');xlabel('迭代次数');ylabel('权向量');title('步长为0.005权向量收敛曲线');figure(3);plot(EA/trials,'*');holdon;plot(EB/trials,'-');xlabel('迭代次数');ylabel('均方误差');title('步长分别为0.05和0.005学习曲线');仿真结果失调参数M1=0.0545M2=0.00524.19程序clearall%产生观测信号和期望信号trials=100;%随机试验的次数data_len=1000;%样本数目n=1:data_len;A1=zeros(data_len,2);EA1=zeros(data_len,1);fori=1:trialssigma_v_2=0.5;phi=2*pi*rand(1,1);%随机相位signal=sin(pi/2*n'+phi);%信号s(n)u=signal+sqrt(sigma_v_2)*randn(data_len,1);%观测信号u(n)d=2*cos(pi/2*n'+phi);%期望响应信号d(n)%LMS迭代算法mu=0.015;M=2;w=zeros(M,data_len);e=zeros(data_len,1);y=zeros(data_len,1);form=2:data_len-1w(:,m+1)=w(:,m)+mu*u(m:-1:m-1)*conj(e(m));y(m+1)=w(:,m+1)'*u(m+1:-1:m);e(m+1)=d(m+1)-y(m+1);endA1=A1+conj(w)';EA1=EA1+e.^2;endfigure(1);plot(e);xlabel('迭代次数');ylabel('均方误差');title('单次实验学习曲线');figure(2);plot(EA1/trials);xlabel('迭代次数');ylabel('均方误差');title('100次独立试验学习曲线');figure(3);plot(A1/trials);holdon;plot(conj(w)');xlabel('迭代次数');ylabel('权向量');title('权向量收敛曲线');仿真结果:5.10(1)247.04846.578346.578347.0487R(2)347.048746.578346.112546.578347.048746.578346.112546.578647.0487R(3)特征值分解eig(R2)=diag{0.4704,93.6270}Eig(R3)=diag{0.3148,0.9362,139.8951}特征值扩展:X(R2)=199.0370X(R3)=444.4107(4)程序clearallclc;L=10000;sigma_v1=0.93627;A1=zeros(L,2);EA1=zeros(L,1);fori=1:100v=sqrt(sigma_v1)*randn(L,1);a1=-0.99;u(1)=v(1);fork=2:Lu(k)=-a1*u(k-1)+v(k);end%u=u(500:end);M=2;w(1,:)=zeros(1,M);e(1)=u(1);mu=0.001;uu=zeros(1,M);w(2,:)=w(1,:)+mu*e(1)*uu;uu=[u(1)uu(1:M-1)];dd=(w(2,:)*uu')';e(2)=u(2)-dd;fork=3:Lw(k,:)=w(k-1,:)+mu*e(k-1)*uu;uu=[u(k-1)uu(1:M-1)];dd=(w(k,:)*uu')';e(k)=u(k)-dd;endA1=A1+conj(w);EA1=EA1+(e.^2)';endfigure(1);plot(EA1/100);xlabel('迭代次数');ylabel('均方误差');title('迭代500次,步长0.001');figure(2);plot(A1/100);holdon;plot(conj(w));xlabel('迭代次数');ylabel('权向量');title('权向量收敛曲线');5.11clearallclear;clc;fori=1:1500N=1000;M=5;L=2;h=[0.38910.389];sigma=1e-3;vn=sqrt(sigma)*randn(2*M+N,1);H=zeros(2*M+1,2*M+L+1);fork=1:2*M+1H(k,k:1:k+L)=h;ends=randsrc(2*M+L+N,1);S=zeros(2*M+L+1,N);V=zeros(2*M+1,N);fork=1:NS(:,k)=s(2*M+L+k:-1:k);V(:,k)=vn(2*M+k:-1:k);endU=H*S+V;dn=S(M+L+1,:);if(i=500)mu=0.01;elseif(i500&&i=1000)mu=0.025;elsemu=0.05;enda=size(U);M=a(1);N=a(2);err=zeros(N,1);w=zeros(M,N);w((M-1)/2+1,1)=1;err(1)=dn(1)-w(:,1)'*U(:,1);fork=1:N-1w(:,k+1)=w(:,k)+mu*U(:,k)*conj(err(k));err(k+1)=dn(k+1)-w(:,k+1)'*U(:,k+1);endif(i=500)ee1(:,i)=mean(abs(err).^2,2);elseif(i500&&i=1000)ee2(:,i)=mean(abs(err).^2,2);elseee3(:,i)=mean(abs(err).^2,2);endendep1=mean(ee1');ep2=mean(ee2');ep3=mean(ee3');figure(1);plot(ep1);holdon;plot(ep2);holdon;plot(ep3)xlabel('µü´ú´ÎÊý');ylabel('¾ù·½Îó²î');

1 / 17
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功